summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2010-12-22 17:15:25 +0000
committerDuncan Sands <baldrick@free.fr>2010-12-22 17:15:25 +0000
commita45cfbd40588a51de1ce4da7f759648788f6dbe9 (patch)
tree20d74bc5a67b3e1f8cb8d8aba30dbc1fb82c660b /llvm/lib/Analysis
parentbab9456f81be0cc30d07b8f939129b75a4f11ace (diff)
downloadbcm5719-llvm-a45cfbd40588a51de1ce4da7f759648788f6dbe9.tar.gz
bcm5719-llvm-a45cfbd40588a51de1ce4da7f759648788f6dbe9.zip
When determining whether the new instruction was already present in
the original instruction, half the cases were missed (making it not wrong but suboptimal). Also correct a typo (A <-> B) in the second chunk. llvm-svn: 122414
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index a720987e52b..fb51fa5315b 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -159,10 +159,11 @@ static Value *FactorizeBinOp(unsigned Opcode, Value *LHS, Value *RHS,
// Does "B op DD" simplify?
if (Value *V = SimplifyBinOp(Opcode, B, DD, TD, DT, MaxRecurse)) {
// It does! Return "A op' V" if it simplifies or is already available.
- // If V equals B then "A op' V" is just the LHS.
- if (V == B) {
+ // If V equals B then "A op' V" is just the LHS. If V equals DD then
+ // "A op' V" is just the RHS.
+ if (V == B || V == DD) {
++NumFactor;
- return LHS;
+ return V == B ? LHS : RHS;
}
// Otherwise return "A op' V" if it simplifies.
if (Value *W = SimplifyBinOp(OpcodeToExtract, A, V, TD, DT, MaxRecurse)) {
@@ -181,10 +182,11 @@ static Value *FactorizeBinOp(unsigned Opcode, Value *LHS, Value *RHS,
// Does "A op CC" simplify?
if (Value *V = SimplifyBinOp(Opcode, A, CC, TD, DT, MaxRecurse)) {
// It does! Return "V op' B" if it simplifies or is already available.
- // If V equals A then "V op' B" is just the LHS.
- if (V == B) {
+ // If V equals A then "V op' B" is just the LHS. If V equals CC then
+ // "V op' B" is just the RHS.
+ if (V == A || V == CC) {
++NumFactor;
- return LHS;
+ return V == A ? LHS : RHS;
}
// Otherwise return "V op' B" if it simplifies.
if (Value *W = SimplifyBinOp(OpcodeToExtract, V, B, TD, DT, MaxRecurse)) {
OpenPOWER on IntegriCloud