diff options
| author | Chad Rosier <mcrosier@codeaurora.org> | 2017-08-23 14:10:06 +0000 |
|---|---|---|
| committer | Chad Rosier <mcrosier@codeaurora.org> | 2017-08-23 14:10:06 +0000 |
| commit | 8db41e9dbd141d9904da6e29d098a49eed933400 (patch) | |
| tree | ab8907a7f9ce70ede359fc4485038a43fab1b6cd /llvm/lib/Transforms/Scalar | |
| parent | 06ed529205634a55e246a8123673de3ce4b79139 (diff) | |
| download | bcm5719-llvm-8db41e9dbd141d9904da6e29d098a49eed933400.tar.gz bcm5719-llvm-8db41e9dbd141d9904da6e29d098a49eed933400.zip | |
[Reassociate] Don't canonicalize x + (-Constant * y) -> x - (Constant * y)..
..if the resulting subtract will be broken up later. This can cause us to get
into an infinite loop.
x + (-5.0 * y) -> x - (5.0 * y) ; Canonicalize neg const
x - (5.0 * y) -> x + (0 - (5.0 * y)) ; Break up subtract
x + (0 - (5.0 * y)) -> x + (-5.0 * y) ; Replace 0-X with X*-1.
PR34078
llvm-svn: 311554
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/Reassociate.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp index 9825a590847..e0ef8cfe46b 100644 --- a/llvm/lib/Transforms/Scalar/Reassociate.cpp +++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp @@ -1938,6 +1938,12 @@ Instruction *ReassociatePass::canonicalizeNegConstExpr(Instruction *I) { if (!User->isCommutative() && User->getOperand(1) != I) return nullptr; + // Don't canonicalize x + (-Constant * y) -> x - (Constant * y), if the + // resulting subtract will be broken up later. This can get us into an + // infinite loop during reassociation. + if (UserOpcode == Instruction::FAdd && ShouldBreakUpSubtract(User)) + return nullptr; + // Change the sign of the constant. APFloat Val = CF->getValueAPF(); Val.changeSign(); |

