@@ -651,7 +651,7 @@ class NewGVN {
651651 BitVector TouchedInstructions;
652652
653653 DenseMap<const BasicBlock *, std::pair<unsigned , unsigned >> BlockInstRange;
654- mutable DenseMap<const IntrinsicInst *, const Value *> IntrinsicInstPred ;
654+ mutable DenseMap<const IntrinsicInst *, const Value *> PredicateSwapChoice ;
655655
656656#ifndef NDEBUG
657657 // Debugging for how many times each block and instruction got processed.
@@ -840,7 +840,7 @@ class NewGVN {
840840 // Ranking
841841 unsigned int getRank (const Value *) const ;
842842 bool shouldSwapOperands (const Value *, const Value *) const ;
843- bool shouldSwapOperandsForIntrinsic (const Value *, const Value *,
843+ bool shouldSwapOperandsForPredicate (const Value *, const Value *,
844844 const IntrinsicInst *I) const ;
845845
846846 // Reachability handling.
@@ -1624,7 +1624,7 @@ NewGVN::performSymbolicPredicateInfoEvaluation(IntrinsicInst *I) const {
16241624 Value *AdditionallyUsedValue = CmpOp0;
16251625
16261626 // Sort the ops.
1627- if (shouldSwapOperandsForIntrinsic (FirstOp, SecondOp, I)) {
1627+ if (shouldSwapOperandsForPredicate (FirstOp, SecondOp, I)) {
16281628 std::swap (FirstOp, SecondOp);
16291629 Predicate = CmpInst::getSwappedPredicate (Predicate);
16301630 AdditionallyUsedValue = CmpOp1;
@@ -3024,7 +3024,7 @@ void NewGVN::cleanupTables() {
30243024 PredicateToUsers.clear ();
30253025 MemoryToUsers.clear ();
30263026 RevisitOnReachabilityChange.clear ();
3027- IntrinsicInstPred .clear ();
3027+ PredicateSwapChoice .clear ();
30283028}
30293029
30303030// 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 {
42504250 return std::make_pair (getRank (A), A) > std::make_pair (getRank (B), B);
42514251}
42524252
4253- bool NewGVN::shouldSwapOperandsForIntrinsic (const Value *A, const Value *B,
4253+ bool NewGVN::shouldSwapOperandsForPredicate (const Value *A, const Value *B,
42544254 const IntrinsicInst *I) const {
4255- auto LookupResult = IntrinsicInstPred.find (I);
42564255 if (shouldSwapOperands (A, B)) {
4257- if (LookupResult == IntrinsicInstPred.end ())
4258- IntrinsicInstPred.insert ({I, B});
4259- else
4260- LookupResult->second = B;
4256+ PredicateSwapChoice[I] = B;
42614257 return true ;
42624258 }
42634259
4264- if (LookupResult != IntrinsicInstPred.end ()) {
4260+ auto LookupResult = PredicateSwapChoice.find (I);
4261+ if (LookupResult != PredicateSwapChoice.end ()) {
42654262 auto *SeenPredicate = LookupResult->second ;
42664263 if (SeenPredicate) {
4264+ // We previously decided to swap B to the left. Keep that choice.
42674265 if (SeenPredicate == B)
42684266 return true ;
42694267 else
0 commit comments