diff options
author | Dan Gohman <gohman@apple.com> | 2009-08-25 22:11:20 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-08-25 22:11:20 +0000 |
commit | 58cfa3b13752579c86cf85270d49f9ced0942f2f (patch) | |
tree | e2d88c43f06255610357c7c9ee6caa8883523454 /lib/Transforms/Scalar/InstructionCombining.cpp | |
parent | 415c8cf837439401f2df75d992d7e296d1d6746a (diff) | |
download | external_llvm-58cfa3b13752579c86cf85270d49f9ced0942f2f.zip external_llvm-58cfa3b13752579c86cf85270d49f9ced0942f2f.tar.gz external_llvm-58cfa3b13752579c86cf85270d49f9ced0942f2f.tar.bz2 |
Rename Instruction::isIdenticalTo to Instruction::isIdenticalToWhenDefined,
and introduce a new Instruction::isIdenticalTo which tests for full
identity, including the SubclassOptionalData flags. Also, fix the
Instruction::clone implementations to preserve the SubclassOptionalData
flags. Finally, teach several optimizations how to handle
SubclassOptionalData correctly, given these changes.
This fixes the counterintuitive behavior of isIdenticalTo not comparing
the full value, and clone not returning an identical clone, as well as
some subtle bugs that could be caused by these.
Thanks to Nick Lewycky for reporting this, and for an initial patch!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80038 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 6dd2641..cca428e 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -11815,12 +11815,16 @@ static bool equivalentAddressValues(Value *A, Value *B) { if (A == B) return true; // Test if the values come form identical arithmetic instructions. + // This uses isIdenticalToWhenDefined instead of isIdenticalTo because + // its only used to compare two uses within the same basic block, which + // means that they'll always either have the same value or one of them + // will have an undefined value. if (isa<BinaryOperator>(A) || isa<CastInst>(A) || isa<PHINode>(A) || isa<GetElementPtrInst>(A)) if (Instruction *BI = dyn_cast<Instruction>(B)) - if (cast<Instruction>(A)->isIdenticalTo(BI)) + if (cast<Instruction>(A)->isIdenticalToWhenDefined(BI)) return true; // Otherwise they may not be equivalent. |