[llvm] 60b8e3a - InstCombine: Pass all parameters to isKnownNeverNaN
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu May 18 00:04:51 PDT 2023
Author: Matt Arsenault
Date: 2023-05-18T08:04:37+01:00
New Revision: 60b8e3a66b64dfb7b7b9d1815018265fd38edaa4
URL: https://github.com/llvm/llvm-project/commit/60b8e3a66b64dfb7b7b9d1815018265fd38edaa4
DIFF: https://github.com/llvm/llvm-project/commit/60b8e3a66b64dfb7b7b9d1815018265fd38edaa4.diff
LOG: InstCombine: Pass all parameters to isKnownNeverNaN
Allows assume handling to work.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/is_fpclass.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index d5b2aa670c60..e1a80737c913 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -7152,10 +7152,12 @@ Instruction *InstCombinerImpl::visitFCmpInst(FCmpInst &I) {
// If we're just checking for a NaN (ORD/UNO) and have a non-NaN operand,
// then canonicalize the operand to 0.0.
if (Pred == CmpInst::FCMP_ORD || Pred == CmpInst::FCMP_UNO) {
- if (!match(Op0, m_PosZeroFP()) && isKnownNeverNaN(Op0, DL, &TLI))
+ if (!match(Op0, m_PosZeroFP()) && isKnownNeverNaN(Op0, DL, &TLI, 0,
+ &AC, &I, &DT, &ORE))
return replaceOperand(I, 0, ConstantFP::getZero(OpType));
- if (!match(Op1, m_PosZeroFP()) && isKnownNeverNaN(Op1, DL, &TLI))
+ if (!match(Op1, m_PosZeroFP()) &&
+ isKnownNeverNaN(Op1, DL, &TLI, 0, &AC, &I, &DT, &ORE))
return replaceOperand(I, 1, ConstantFP::getZero(OpType));
}
diff --git a/llvm/test/Transforms/InstCombine/is_fpclass.ll b/llvm/test/Transforms/InstCombine/is_fpclass.ll
index bb76fdfc88fc..b9371287a684 100644
--- a/llvm/test/Transforms/InstCombine/is_fpclass.ll
+++ b/llvm/test/Transforms/InstCombine/is_fpclass.ll
@@ -2712,8 +2712,7 @@ define i1 @test_class_is_nan_assume_ord(float %x) {
; CHECK-LABEL: @test_class_is_nan_assume_ord(
; CHECK-NEXT: [[ORD:%.*]] = fcmp ord float [[X:%.*]], 0.000000e+00
; CHECK-NEXT: call void @llvm.assume(i1 [[ORD]])
-; CHECK-NEXT: [[CLASS:%.*]] = fcmp uno float [[X]], 0.000000e+00
-; CHECK-NEXT: ret i1 [[CLASS]]
+; CHECK-NEXT: ret i1 false
;
%ord = fcmp ord float %x, 0.0
call void @llvm.assume(i1 %ord)
@@ -2738,8 +2737,7 @@ define i1 @test_class_is_nan_assume_not_eq_pinf(float %x) {
; CHECK-LABEL: @test_class_is_nan_assume_not_eq_pinf(
; CHECK-NEXT: [[ORD:%.*]] = fcmp oeq float [[X:%.*]], 0x7FF0000000000000
; CHECK-NEXT: call void @llvm.assume(i1 [[ORD]])
-; CHECK-NEXT: [[CLASS:%.*]] = fcmp uno float [[X]], 0.000000e+00
-; CHECK-NEXT: ret i1 [[CLASS]]
+; CHECK-NEXT: ret i1 false
;
%ord = fcmp oeq float %x, 0x7FF0000000000000
call void @llvm.assume(i1 %ord)
More information about the llvm-commits
mailing list