[llvm] e6fa09f - [SCCP] Add context to SimplifyQuery (#100831)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 29 06:22:01 PDT 2024


Author: Thomas Hashem
Date: 2024-07-29T15:21:57+02:00
New Revision: e6fa09f445f172bfd0c011adc6bf36e38816b781

URL: https://github.com/llvm/llvm-project/commit/e6fa09f445f172bfd0c011adc6bf36e38816b781
DIFF: https://github.com/llvm/llvm-project/commit/e6fa09f445f172bfd0c011adc6bf36e38816b781.diff

LOG: [SCCP] Add context to SimplifyQuery (#100831)

Added: 
    llvm/test/Transforms/SCCP/float-denormal-simplification.ll

Modified: 
    llvm/lib/Transforms/Utils/SCCPSolver.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/SCCPSolver.cpp b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
index 2336466a25a17..c944859cc69b8 100644
--- a/llvm/lib/Transforms/Utils/SCCPSolver.cpp
+++ b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
@@ -1503,7 +1503,7 @@ void SCCPInstVisitor::visitBinaryOperator(Instruction &I) {
     Value *V2 = SCCPSolver::isConstant(V2State)
                     ? getConstant(V2State, I.getOperand(1)->getType())
                     : I.getOperand(1);
-    Value *R = simplifyBinOp(I.getOpcode(), V1, V2, SimplifyQuery(DL));
+    Value *R = simplifyBinOp(I.getOpcode(), V1, V2, SimplifyQuery(DL, &I));
     auto *C = dyn_cast_or_null<Constant>(R);
     if (C) {
       // Conservatively assume that the result may be based on operands that may

diff  --git a/llvm/test/Transforms/SCCP/float-denormal-simplification.ll b/llvm/test/Transforms/SCCP/float-denormal-simplification.ll
new file mode 100644
index 0000000000000..fec9883aabddd
--- /dev/null
+++ b/llvm/test/Transforms/SCCP/float-denormal-simplification.ll
@@ -0,0 +1,21 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -passes=sccp -S %s | FileCheck %s
+
+define float @test_ieee() #0 {
+; CHECK-LABEL: @test_ieee(
+; CHECK-NEXT:    ret float 0x36F4000000000000
+;
+  %1 = fmul float 2.802596928649634e-44, 2.000000e+00
+  ret float %1
+}
+
+define float @test_preserve_sign() #1 {
+; CHECK-LABEL: @test_preserve_sign(
+; CHECK-NEXT:    ret float 0.000000e+00
+;
+  %1 = fmul float 2.802596928649634e-44, 2.000000e+00
+  ret float %1
+}
+
+attributes #0 = {"denormal-fp-math"="ieee,ieee"}
+attributes #1 = {"denormal-fp-math"="preserve-sign,preserve-sign"}


        


More information about the llvm-commits mailing list