[llvm] InstCombine: Apply demanded mask at recursion limit in SimplifyDemandedFPClass (PR #178157)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 27 02:49:04 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Matt Arsenault (arsenm)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/178157.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp (+5-3)
- (modified) llvm/test/Transforms/InstCombine/simplify-demanded-fpclass.ll (+1-1)
``````````diff
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 61e93e0398be7..ff56982c4ff5e 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 b76b945e92adc..c832aeb1ac0ef 100644
--- a/llvm/test/Transforms/InstCombine/simplify-demanded-fpclass.ll
+++ b/llvm/test/Transforms/InstCombine/simplify-demanded-fpclass.ll
@@ -1294,7 +1294,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]])
``````````
</details>
https://github.com/llvm/llvm-project/pull/178157
More information about the llvm-commits
mailing list