[PATCH] D14072: [FPEnv Core 07/14] Prevent undesired folding by InstSimplify
Sergey Dmitrouk via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 26 06:56:12 PDT 2015
sdmitrouk created this revision.
sdmitrouk added reviewers: hfinkel, joker.eph.
sdmitrouk added subscribers: llvm-commits, resistor, scanon.
sdmitrouk set the repository for this revision to rL LLVM.
Repository:
rL LLVM
http://reviews.llvm.org/D14072
Files:
lib/Analysis/InstructionSimplify.cpp
test/Transforms/InstSimplify/fast-math.ll
Index: test/Transforms/InstSimplify/fast-math.ll
===================================================================
--- test/Transforms/InstSimplify/fast-math.ll
+++ test/Transforms/InstSimplify/fast-math.ll
@@ -171,3 +171,51 @@
; CHECK-LABEL: fdiv_neg_swapped2
; CHECK: ret float -1.000000e+00
}
+
+; CHECK-LABEL: @nofold_fadd_kexc(
+define double @nofold_fadd_kexc() {
+; CHECK: fadd
+entry:
+ %val = fadd kexc double 1.000000e+308, 1.000000e+308
+ ret double %val
+}
+
+; CHECK-LABEL: @nofold_fsub_kexc(
+define double @nofold_fsub_kexc() {
+; CHECK: fsub
+entry:
+ %val = fsub kexc double 1.000000e-308, 1.000000e+308
+ ret double %val
+}
+
+; CHECK-LABEL: @nofold_fmul_kexc(
+define double @nofold_fmul_kexc() {
+; CHECK: fmul
+entry:
+ %val = fmul kexc double 1.000000e+300, 1.000000e+300
+ ret double %val
+}
+
+; CHECK-LABEL: @nofold_fadd_kround(
+define double @nofold_fadd_kround() {
+; CHECK: fadd
+entry:
+ %val = fadd kround double 1.000000e+308, 1.000000e+308
+ ret double %val
+}
+
+; CHECK-LABEL: @nofold_fsub_kround(
+define double @nofold_fsub_kround() {
+; CHECK: fsub
+entry:
+ %val = fsub kround double 1.000000e-308, 1.000000e+308
+ ret double %val
+}
+
+; CHECK-LABEL: @nofold_fmul_kround(
+define double @nofold_fmul_kround() {
+; CHECK: fmul
+entry:
+ %val = fmul kround double 1.000000e+300, 1.000000e+300
+ ret double %val
+}
Index: lib/Analysis/InstructionSimplify.cpp
===================================================================
--- lib/Analysis/InstructionSimplify.cpp
+++ lib/Analysis/InstructionSimplify.cpp
@@ -791,7 +791,7 @@
if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
Constant *Ops[] = { CLHS, CRHS };
return ConstantFoldInstOperands(Instruction::FAdd, CLHS->getType(),
- Ops, Q.DL, Q.TLI);
+ Ops, Q.DL, Q.TLI, FMF);
}
// Canonicalize the constant to the RHS.
@@ -833,7 +833,7 @@
if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
Constant *Ops[] = { CLHS, CRHS };
return ConstantFoldInstOperands(Instruction::FSub, CLHS->getType(),
- Ops, Q.DL, Q.TLI);
+ Ops, Q.DL, Q.TLI, FMF);
}
}
@@ -871,7 +871,7 @@
if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
Constant *Ops[] = { CLHS, CRHS };
return ConstantFoldInstOperands(Instruction::FMul, CLHS->getType(),
- Ops, Q.DL, Q.TLI);
+ Ops, Q.DL, Q.TLI, FMF);
}
// Canonicalize the constant to the RHS.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14072.38405.patch
Type: text/x-patch
Size: 2617 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151026/86ecce24/attachment.bin>
More information about the llvm-commits
mailing list