mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
[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! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220615 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user