diff options
author | Sanjay Patel <spatel@rotateright.com> | 2019-11-17 11:23:44 -0500 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2019-11-17 11:23:44 -0500 |
commit | ebf9bf2cbc8fa68d536e481e370c4ba40ce61a8a (patch) | |
tree | 32eb0ae80a2bc8e698052dfeb287358abe3a27f5 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 23f736059c704b95643dfc63425444044b57a973 (diff) | |
download | bcm5719-llvm-ebf9bf2cbc8fa68d536e481e370c4ba40ce61a8a.tar.gz bcm5719-llvm-ebf9bf2cbc8fa68d536e481e370c4ba40ce61a8a.zip |
[SimplifyCFG] propagate fast-math-flags (FMF) from phi to select
Similar to/extension of D70208 (rGee0882bdf866), but this one
may finally allow closing motivating bugs.
This is another step towards having FMF apply only to FP values
rather than those + fcmp. See PR38086 for one of the original
discussions/motivations:
https://bugs.llvm.org/show_bug.cgi?id=38086
And the test here is derived from PR39535:
https://bugs.llvm.org/show_bug.cgi?id=39535
Currently, we lose FMF when converting any phi to select in
SimplifyCFG. There are a small number of similar changes needed
to correct within SimplifyCFG, so it should be quick to patch
this pass up.
FMF was extended to select and phi with:
D61917
D67564
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index ab1a474db9a..79d4857c2c8 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -2425,7 +2425,12 @@ static bool FoldTwoEntryPHINode(PHINode *PN, const TargetTransformInfo &TTI, if (IfBlock2) hoistAllInstructionsInto(DomBlock, InsertPt, IfBlock2); + // Propagate fast-math-flags from phi nodes to replacement selects. + IRBuilder<>::FastMathFlagGuard FMFGuard(Builder); while (PHINode *PN = dyn_cast<PHINode>(BB->begin())) { + if (isa<FPMathOperator>(PN)) + Builder.setFastMathFlags(PN->getFastMathFlags()); + // Change the PHI node into a select instruction. Value *TrueVal = PN->getIncomingValue(PN->getIncomingBlock(0) == IfFalse); Value *FalseVal = PN->getIncomingValue(PN->getIncomingBlock(0) == IfTrue); |