[llvm] [SCCP] Add context to SimplifyQuery (PR #100831)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 26 16:03:21 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-function-specialization
Author: Thomas Hashem (hashemthomas1)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/100831.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/Utils/SCCPSolver.cpp (+1-1)
- (added) llvm/test/Transforms/SCCP/float-denormal-simplification.ll (+21)
``````````diff
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..7a1461ab068a7
--- /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 dso_local 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 dso_local 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"}
``````````
</details>
https://github.com/llvm/llvm-project/pull/100831
More information about the llvm-commits
mailing list