diff options
| author | Jingyue Wu <jingyue@google.com> | 2014-10-25 17:36:21 +0000 |
|---|---|---|
| committer | Jingyue Wu <jingyue@google.com> | 2014-10-25 17:36:21 +0000 |
| commit | b723152379709d4bc4e5d91a92c48b509880e9f2 (patch) | |
| tree | 9be7a834608d8c12b25b86490b33441416fcb3ce /llvm/lib/Transforms | |
| parent | d3c3e78ac17602420ca05b1ce1ed7d20ba9c5ede (diff) | |
| download | bcm5719-llvm-b723152379709d4bc4e5d91a92c48b509880e9f2.tar.gz bcm5719-llvm-b723152379709d4bc4e5d91a92c48b509880e9f2.zip | |
[SeparateConstOffsetFromGEP] Fixed a bug in rebuilding OR expressions
The two operands of the new OR expression should be NextInChain and TheOther
instead of the two original operands.
Added a regression test in split-gep.ll.
Hao Liu reported this bug, and provded the test case and an initial patch.
Thanks!
llvm-svn: 220615
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp b/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp index 6557ce4575d..449198c1d2f 100644 --- a/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp +++ b/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp @@ -519,8 +519,13 @@ Value *ConstantOffsetExtractor::removeConstOffset(unsigned ChainIndex) { // // Replacing the "or" with "add" is fine, because // a | (b + 5) = a + (b + 5) = (a + b) + 5 - return BinaryOperator::CreateAdd(BO->getOperand(0), BO->getOperand(1), - BO->getName(), IP); + if (OpNo == 0) { + return BinaryOperator::CreateAdd(NextInChain, TheOther, BO->getName(), + IP); + } else { + return BinaryOperator::CreateAdd(TheOther, NextInChain, BO->getName(), + IP); + } } // We can reuse BO in this case, because the new expression shares the same |

