[llvm] ff79d7d - InstCombine: Apply demanded mask at recursion limit in SimplifyDemandedFPClass (#178157)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 27 09:20:00 PST 2026
Author: Matt Arsenault
Date: 2026-01-27T18:19:55+01:00
New Revision: ff79d7d1bf0415e52ad542b059c55f0e92b3bad6
URL: https://github.com/llvm/llvm-project/commit/ff79d7d1bf0415e52ad542b059c55f0e92b3bad6
DIFF: https://github.com/llvm/llvm-project/commit/ff79d7d1bf0415e52ad542b059c55f0e92b3bad6.diff
LOG: InstCombine: Apply demanded mask at recursion limit in SimplifyDemandedFPClass (#178157)
This fixes missed flag inference in some cases, due to not inferring
no-nan result implies no-nan source. Also start treating explicit
nofpclass
attributes as a leaf value, like a constant or argument.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
llvm/test/Transforms/InstCombine/simplify-demanded-fpclass.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index d9e9c25b4fb45..25df44e94699d 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -3423,14 +3423,16 @@ bool InstCombinerImpl::SimplifyDemandedFPClass(Instruction *I, unsigned OpNo,
return true;
}
- if (Depth == MaxAnalysisRecursionDepth)
- return false;
-
if (const CallBase *CB = dyn_cast<CallBase>(VInst)) {
FPClassTest NoFPClass = CB->getParamNoFPClass(U.getOperandNo());
DemandedMask &= ~NoFPClass;
}
+ if (Depth == MaxAnalysisRecursionDepth) {
+ Known.knownNot(~DemandedMask);
+ return false;
+ }
+
Value *NewVal;
if (VInst->hasOneUse()) {
diff --git a/llvm/test/Transforms/InstCombine/simplify-demanded-fpclass.ll b/llvm/test/Transforms/InstCombine/simplify-demanded-fpclass.ll
index 48a7514c07d66..e10c920a9ae9a 100644
--- a/llvm/test/Transforms/InstCombine/simplify-demanded-fpclass.ll
+++ b/llvm/test/Transforms/InstCombine/simplify-demanded-fpclass.ll
@@ -1311,7 +1311,7 @@ define nofpclass(nan inf) float @pow_f32(float nofpclass(nan inf) %arg, float no
; CHECK-SAME: (float nofpclass(nan inf) [[ARG:%.*]], float nofpclass(nan inf) [[ARG1:%.*]]) {
; CHECK-NEXT: bb:
; CHECK-NEXT: [[I:%.*]] = tail call nofpclass(ninf nzero nsub nnorm) float @llvm.fabs.f32(float noundef [[ARG]])
-; CHECK-NEXT: [[I2:%.*]] = tail call float @llvm.log2.f32(float noundef [[I]])
+; CHECK-NEXT: [[I2:%.*]] = tail call nnan float @llvm.log2.f32(float [[I]])
; CHECK-NEXT: [[I3:%.*]] = fmul nnan float [[I2]], [[ARG1]]
; CHECK-NEXT: [[I4:%.*]] = tail call nnan float @llvm.exp2.f32(float [[I3]])
; CHECK-NEXT: [[I5:%.*]] = tail call nofpclass(ninf nzero nsub nnorm) float @llvm.fabs.f32(float noundef [[ARG1]])
More information about the llvm-commits
mailing list