[PATCH] D14071: [FPEnv Core 06/14] Do not fold constants on reading in IR asm/bitcode
Sergey Dmitrouk via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 26 06:56:09 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/D14071
Files:
lib/AsmParser/LLParser.cpp
lib/Bitcode/Reader/BitcodeReader.cpp
test/Assembler/do-not-fold-fp-consts.ll
Index: test/Assembler/do-not-fold-fp-consts.ll
===================================================================
--- /dev/null
+++ test/Assembler/do-not-fold-fp-consts.ll
@@ -0,0 +1,36 @@
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+define double @do-not-fold-fadd() {
+; CHECK-LABEL: @do-not-fold-fadd
+; CHECK: fadd
+entry:
+ ret double fadd (double 1.000000e+308, double 1.000000e+308)
+}
+
+define double @do-not-fold-fsub() {
+; CHECK-LABEL: @do-not-fold-fsub
+; CHECK: fsub
+entry:
+ ret double fsub (double 1.000000e-308, double 1.000000e+308)
+}
+
+define double @do-not-fold-fmul() {
+; CHECK-LABEL: @do-not-fold-fmul
+; CHECK: fmul
+entry:
+ ret double fmul (double 1.000000e+300, double 1.000000e+300)
+}
+
+define double @do-not-fold-fdiv() {
+; CHECK-LABEL: @do-not-fold-fdiv
+; CHECK: fdiv
+entry:
+ ret double fdiv (double 1.000000e+300, double 1.000000e-300)
+}
+
+define double @do-not-fold-frem() {
+; CHECK-LABEL: @do-not-fold-frem
+; CHECK: frem
+entry:
+ ret double frem (double 1.000000e+300, double 1.000000e-300)
+}
Index: lib/Bitcode/Reader/BitcodeReader.cpp
===================================================================
--- lib/Bitcode/Reader/BitcodeReader.cpp
+++ lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2642,7 +2642,10 @@
Flags |= SDivOperator::IsExact;
}
}
- V = ConstantExpr::get(Opc, LHS, RHS, Flags);
+ FastMathFlags FMF;
+ FMF.setKeepExceptions();
+ FMF.setKeepRounding();
+ V = ConstantExpr::get(Opc, LHS, RHS, Flags, nullptr, FMF);
}
break;
}
Index: lib/AsmParser/LLParser.cpp
===================================================================
--- lib/AsmParser/LLParser.cpp
+++ lib/AsmParser/LLParser.cpp
@@ -3003,11 +3003,17 @@
break;
default: llvm_unreachable("Unknown binary operator!");
}
+
unsigned Flags = 0;
if (NUW) Flags |= OverflowingBinaryOperator::NoUnsignedWrap;
if (NSW) Flags |= OverflowingBinaryOperator::NoSignedWrap;
if (Exact) Flags |= PossiblyExactOperator::IsExact;
- Constant *C = ConstantExpr::get(Opc, Val0, Val1, Flags);
+
+ FastMathFlags FMF;
+ FMF.setKeepExceptions();
+ FMF.setKeepRounding();
+
+ Constant *C = ConstantExpr::get(Opc, Val0, Val1, Flags, nullptr, FMF);
ID.ConstantVal = C;
ID.Kind = ValID::t_Constant;
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14071.38404.patch
Type: text/x-patch
Size: 2375 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151026/779453ab/attachment.bin>
More information about the llvm-commits
mailing list