[PATCH] D14072: [FPEnv Core 07/14] Prevent undesired folding by InstSimplify
Sergey Dmitrouk via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 4 12:08:14 PST 2015
sdmitrouk updated this revision to Diff 41915.
sdmitrouk added a comment.
Changes required due to updated of patches that go before this one.
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_nexc(
+define double @nofold_fadd_nexc() {
+; CHECK: fadd
+entry:
+ %val = fadd nrnd double 1.000000e+308, 1.000000e+308
+ ret double %val
+}
+
+; CHECK-LABEL: @nofold_fsub_nexc(
+define double @nofold_fsub_nexc() {
+; CHECK: fsub
+entry:
+ %val = fsub nrnd double 1.000000e-308, 1.000000e+308
+ ret double %val
+}
+
+; CHECK-LABEL: @nofold_fmul_nexc(
+define double @nofold_fmul_nexc() {
+; CHECK: fmul
+entry:
+ %val = fmul nrnd double 1.000000e+300, 1.000000e+300
+ ret double %val
+}
+
+; CHECK-LABEL: @nofold_fadd_nrnd(
+define double @nofold_fadd_nrnd() {
+; CHECK: fadd
+entry:
+ %val = fadd nexc double 1.000000e+308, 1.000000e+308
+ ret double %val
+}
+
+; CHECK-LABEL: @nofold_fsub_nrnd(
+define double @nofold_fsub_nrnd() {
+; CHECK: fsub
+entry:
+ %val = fsub nexc double 1.000000e-308, 1.000000e+308
+ ret double %val
+}
+
+; CHECK-LABEL: @nofold_fmul_nrnd(
+define double @nofold_fmul_nrnd() {
+; CHECK: fmul
+entry:
+ %val = fmul nexc 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.41915.patch
Type: text/x-patch
Size: 2599 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151204/01b58d79/attachment.bin>
More information about the llvm-commits
mailing list