[llvm] [SCCP] Add context to SimplifyQuery (PR #100831)
Thomas Hashem via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 26 16:02:28 PDT 2024
https://github.com/hashemthomas1 created https://github.com/llvm/llvm-project/pull/100831
None
>From b9b4817bef3cc3a0425db047761767222432ac8d Mon Sep 17 00:00:00 2001
From: Thomas Hashem <hashemthomas1 at gmail.com>
Date: Sat, 27 Jul 2024 00:12:02 +0300
Subject: [PATCH] [SCCP] Add context to SimplifyQuery
---
llvm/lib/Transforms/Utils/SCCPSolver.cpp | 2 +-
.../SCCP/float-denormal-simplification.ll | 21 +++++++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/Transforms/SCCP/float-denormal-simplification.ll
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"}
More information about the llvm-commits
mailing list