|
27 | 27 | #include "llvm/Analysis/CmpInstAnalysis.h" |
28 | 28 | #include "llvm/Analysis/ConstantFolding.h" |
29 | 29 | #include "llvm/Analysis/InstSimplifyFolder.h" |
| 30 | +#include "llvm/Analysis/Loads.h" |
30 | 31 | #include "llvm/Analysis/LoopAnalysisManager.h" |
31 | 32 | #include "llvm/Analysis/MemoryBuiltins.h" |
32 | 33 | #include "llvm/Analysis/OverflowInstAnalysis.h" |
@@ -4731,12 +4732,16 @@ static Value *simplifySelectWithICmpCond(Value *CondVal, Value *TrueVal, |
4731 | 4732 | // the arms of the select. See if substituting this value into the arm and |
4732 | 4733 | // simplifying the result yields the same value as the other arm. |
4733 | 4734 | if (Pred == ICmpInst::ICMP_EQ) { |
4734 | | - if (Value *V = simplifySelectWithEquivalence({{CmpLHS, CmpRHS}}, TrueVal, |
4735 | | - FalseVal, Q, MaxRecurse)) |
4736 | | - return V; |
4737 | | - if (Value *V = simplifySelectWithEquivalence({{CmpRHS, CmpLHS}}, TrueVal, |
4738 | | - FalseVal, Q, MaxRecurse)) |
4739 | | - return V; |
| 4735 | + if (CmpLHS->getType()->isIntOrIntVectorTy() || |
| 4736 | + canReplacePointersIfEqual(CmpLHS, CmpRHS, Q.DL)) |
| 4737 | + if (Value *V = simplifySelectWithEquivalence({{CmpLHS, CmpRHS}}, TrueVal, |
| 4738 | + FalseVal, Q, MaxRecurse)) |
| 4739 | + return V; |
| 4740 | + if (CmpLHS->getType()->isIntOrIntVectorTy() || |
| 4741 | + canReplacePointersIfEqual(CmpRHS, CmpLHS, Q.DL)) |
| 4742 | + if (Value *V = simplifySelectWithEquivalence({{CmpRHS, CmpLHS}}, TrueVal, |
| 4743 | + FalseVal, Q, MaxRecurse)) |
| 4744 | + return V; |
4740 | 4745 |
|
4741 | 4746 | Value *X; |
4742 | 4747 | Value *Y; |
|
0 commit comments