|
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"
|
@@ -4737,12 +4738,16 @@ static Value *simplifySelectWithICmpCond(Value *CondVal, Value *TrueVal,
|
4737 | 4738 | // the arms of the select. See if substituting this value into the arm and
|
4738 | 4739 | // simplifying the result yields the same value as the other arm.
|
4739 | 4740 | if (Pred == ICmpInst::ICMP_EQ) {
|
4740 |
| - if (Value *V = simplifySelectWithEquivalence({{CmpLHS, CmpRHS}}, TrueVal, |
4741 |
| - FalseVal, Q, MaxRecurse)) |
4742 |
| - return V; |
4743 |
| - if (Value *V = simplifySelectWithEquivalence({{CmpRHS, CmpLHS}}, TrueVal, |
4744 |
| - FalseVal, Q, MaxRecurse)) |
4745 |
| - return V; |
| 4741 | + if (CmpLHS->getType()->isIntOrIntVectorTy() || |
| 4742 | + canReplacePointersIfEqual(CmpLHS, CmpRHS, Q.DL)) |
| 4743 | + if (Value *V = simplifySelectWithEquivalence({{CmpLHS, CmpRHS}}, TrueVal, |
| 4744 | + FalseVal, Q, MaxRecurse)) |
| 4745 | + return V; |
| 4746 | + if (CmpLHS->getType()->isIntOrIntVectorTy() || |
| 4747 | + canReplacePointersIfEqual(CmpRHS, CmpLHS, Q.DL)) |
| 4748 | + if (Value *V = simplifySelectWithEquivalence({{CmpRHS, CmpLHS}}, TrueVal, |
| 4749 | + FalseVal, Q, MaxRecurse)) |
| 4750 | + return V; |
4746 | 4751 |
|
4747 | 4752 | Value *X;
|
4748 | 4753 | Value *Y;
|
|
0 commit comments