@@ -651,7 +651,7 @@ class NewGVN {
651
651
BitVector TouchedInstructions;
652
652
653
653
DenseMap<const BasicBlock *, std::pair<unsigned , unsigned >> BlockInstRange;
654
- mutable DenseMap<const IntrinsicInst *, const Value *> IntrinsicInstPred ;
654
+ mutable DenseMap<const IntrinsicInst *, const Value *> PredicateSwapChoice ;
655
655
656
656
#ifndef NDEBUG
657
657
// Debugging for how many times each block and instruction got processed.
@@ -840,7 +840,7 @@ class NewGVN {
840
840
// Ranking
841
841
unsigned int getRank (const Value *) const ;
842
842
bool shouldSwapOperands (const Value *, const Value *) const ;
843
- bool shouldSwapOperandsForIntrinsic (const Value *, const Value *,
843
+ bool shouldSwapOperandsForPredicate (const Value *, const Value *,
844
844
const IntrinsicInst *I) const ;
845
845
846
846
// Reachability handling.
@@ -1624,7 +1624,7 @@ NewGVN::performSymbolicPredicateInfoEvaluation(IntrinsicInst *I) const {
1624
1624
Value *AdditionallyUsedValue = CmpOp0;
1625
1625
1626
1626
// Sort the ops.
1627
- if (shouldSwapOperandsForIntrinsic (FirstOp, SecondOp, I)) {
1627
+ if (shouldSwapOperandsForPredicate (FirstOp, SecondOp, I)) {
1628
1628
std::swap (FirstOp, SecondOp);
1629
1629
Predicate = CmpInst::getSwappedPredicate (Predicate);
1630
1630
AdditionallyUsedValue = CmpOp1;
@@ -3024,7 +3024,7 @@ void NewGVN::cleanupTables() {
3024
3024
PredicateToUsers.clear ();
3025
3025
MemoryToUsers.clear ();
3026
3026
RevisitOnReachabilityChange.clear ();
3027
- IntrinsicInstPred .clear ();
3027
+ PredicateSwapChoice .clear ();
3028
3028
}
3029
3029
3030
3030
// Assign local DFS number mapping to instructions, and leave space for Value
@@ -4250,20 +4250,18 @@ bool NewGVN::shouldSwapOperands(const Value *A, const Value *B) const {
4250
4250
return std::make_pair (getRank (A), A) > std::make_pair (getRank (B), B);
4251
4251
}
4252
4252
4253
- bool NewGVN::shouldSwapOperandsForIntrinsic (const Value *A, const Value *B,
4253
+ bool NewGVN::shouldSwapOperandsForPredicate (const Value *A, const Value *B,
4254
4254
const IntrinsicInst *I) const {
4255
- auto LookupResult = IntrinsicInstPred.find (I);
4256
4255
if (shouldSwapOperands (A, B)) {
4257
- if (LookupResult == IntrinsicInstPred.end ())
4258
- IntrinsicInstPred.insert ({I, B});
4259
- else
4260
- LookupResult->second = B;
4256
+ PredicateSwapChoice[I] = B;
4261
4257
return true ;
4262
4258
}
4263
4259
4264
- if (LookupResult != IntrinsicInstPred.end ()) {
4260
+ auto LookupResult = PredicateSwapChoice.find (I);
4261
+ if (LookupResult != PredicateSwapChoice.end ()) {
4265
4262
auto *SeenPredicate = LookupResult->second ;
4266
4263
if (SeenPredicate) {
4264
+ // We previously decided to swap B to the left. Keep that choice.
4267
4265
if (SeenPredicate == B)
4268
4266
return true ;
4269
4267
else
0 commit comments