summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2019-12-05 10:50:43 -0500
committerSanjay Patel <spatel@rotateright.com>2019-12-05 10:55:07 -0500
commit51e420c27e2dc493bd71a6305ffb4d8acb401755 (patch)
treef8648d4a079968bb9880413c222a1f7c70cebc38 /llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
parent30e8f80fd5a43a213f8feb124846223b61218f30 (diff)
downloadbcm5719-llvm-51e420c27e2dc493bd71a6305ffb4d8acb401755.tar.gz
bcm5719-llvm-51e420c27e2dc493bd71a6305ffb4d8acb401755.zip
[InstCombine] add FMF guard to builder in fptrunc transform; NFC
This makes no difference currently because we don't apply FMF to FP casts, but that may change. This could also be a place to add a fold for select with fptrunc, so it will make that patch easier/smaller.
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 2171c819fd9..53bcaeb98b4 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -1622,6 +1622,11 @@ Instruction *InstCombiner::visitFPTrunc(FPTruncInst &FPT) {
Value *X;
Instruction *Op = dyn_cast<Instruction>(FPT.getOperand(0));
if (Op && Op->hasOneUse()) {
+ // FIXME: The FMF should propagate from the fptrunc, not the source op.
+ IRBuilder<>::FastMathFlagGuard FMFG(Builder);
+ if (isa<FPMathOperator>(Op))
+ Builder.setFastMathFlags(Op->getFastMathFlags());
+
if (match(Op, m_FNeg(m_Value(X)))) {
Value *InnerTrunc = Builder.CreateFPTrunc(X, Ty);
OpenPOWER on IntegriCloud