diff options
author | Craig Topper <craig.topper@gmail.com> | 2017-04-10 07:00:10 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2017-04-10 07:00:10 +0000 |
commit | 838d13e7ee6168ec31822b8278949cfe6266ac1e (patch) | |
tree | 69d4e9ce5ba2c2dceb96bb1a918c2f0aeb0bc45f /llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | |
parent | d8840d7b101d6958e1746183b8e7d09e16e07c55 (diff) | |
download | bcm5719-llvm-838d13e7ee6168ec31822b8278949cfe6266ac1e.tar.gz bcm5719-llvm-838d13e7ee6168ec31822b8278949cfe6266ac1e.zip |
[InstCombine] Make sure we preserve fast math flags when folding fp instructions into phi nodes
Summary: I noticed in the select folding code that we copied fast math flags, but did not do the same for the similar handling in phi nodes. This patch fixes that to do the same thing as select
Reviewers: spatel, davide, majnemer, hfinkel
Reviewed By: davide
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D31690
llvm-svn: 299838
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstructionCombining.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index bc168dd5776..398b49748ec 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -937,11 +937,15 @@ Instruction *InstCombiner::FoldOpIntoPhi(Instruction &I) { Constant *C = cast<Constant>(I.getOperand(1)); for (unsigned i = 0; i != NumPHIValues; ++i) { Value *InV = nullptr; - if (Constant *InC = dyn_cast<Constant>(PN->getIncomingValue(i))) + if (Constant *InC = dyn_cast<Constant>(PN->getIncomingValue(i))) { InV = ConstantExpr::get(I.getOpcode(), InC, C); - else + } else { InV = Builder->CreateBinOp(cast<BinaryOperator>(I).getOpcode(), PN->getIncomingValue(i), C, "phitmp"); + auto *FPInst = dyn_cast<Instruction>(InV); + if (FPInst && isa<FPMathOperator>(FPInst)) + FPInst->copyFastMathFlags(&I); + } NewPN->addIncoming(InV, PN->getIncomingBlock(i)); } } else { |