diff options
author | Craig Topper <craig.topper@gmail.com> | 2017-04-14 19:20:12 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2017-04-14 19:20:12 +0000 |
commit | fb71b7d3e05c347a05a7607d39bd04bf281c1529 (patch) | |
tree | fdb7777aee84ae471113afa2cf66a1c897949579 /llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp | |
parent | eff0bc78395432f2afe470b037186bb9f4aa9940 (diff) | |
download | bcm5719-llvm-fb71b7d3e05c347a05a7607d39bd04bf281c1529.tar.gz bcm5719-llvm-fb71b7d3e05c347a05a7607d39bd04bf281c1529.zip |
[InstCombine] Support folding a subtract with a constant LHS into a phi node
We currently only support folding a subtract into a select but not a PHI. This fixes that.
I had to fix an assumption in FoldOpIntoPhi that assumed the PHI node was always in operand 0. Now we pass it in like we do for FoldOpIntoSelect. But we still require some dancing to find the Constant when we create the BinOp or ConstantExpr. This is based code is similar to what we do for selects.
Since I touched all call sites, this also renames FoldOpIntoPhi to foldOpIntoPhi to match coding standards.
Differential Revision: https://reviews.llvm.org/D31686
llvm-svn: 300363
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp index d8574175307..85e5b6ba2dc 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp @@ -457,8 +457,8 @@ Instruction *InstCombiner::FoldPHIArgZextsIntoPHI(PHINode &Phi) { } // The more common cases of a phi with no constant operands or just one - // variable operand are handled by FoldPHIArgOpIntoPHI() and FoldOpIntoPhi() - // respectively. FoldOpIntoPhi() wants to do the opposite transform that is + // variable operand are handled by FoldPHIArgOpIntoPHI() and foldOpIntoPhi() + // respectively. foldOpIntoPhi() wants to do the opposite transform that is // performed here. It tries to replicate a cast in the phi operand's basic // block to expose other folding opportunities. Thus, InstCombine will // infinite loop without this check. |