Skip to content

Commit 44706bd

Browse files
authored
[InstCombine] Don't add fcmp instructions to strictfp functions (#81498)
The strictfp attribute has the requirement that "LLVM will not introduce any new floating-point instructions that may trap". The llvm.is.fpclass intrinsic is documented as "The function never raises floating-point exceptions", and the fcmp instruction may raise one, so we can't transform the former into the latter in functions with the strictfp attribute.
1 parent d860ea9 commit 44706bd

File tree

2 files changed

+316
-10
lines changed

2 files changed

+316
-10
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,8 @@ Instruction *InstCombinerImpl::foldIntrinsicIsFPClass(IntrinsicInst &II) {
902902
const FPClassTest OrderedMask = Mask & ~fcNan;
903903
const FPClassTest OrderedInvertedMask = ~OrderedMask & ~fcNan;
904904

905-
const bool IsStrict = II.isStrictFP();
905+
const bool IsStrict =
906+
II.getFunction()->getAttributes().hasFnAttr(Attribute::StrictFP);
906907

907908
Value *FNegSrc;
908909
if (match(Src0, m_FNeg(m_Value(FNegSrc)))) {

0 commit comments

Comments
 (0)