[llvm] 42ce628 - [ValueTracking] Handle incompatible types instead of asserting in `isKnownNonEqual`; NFC

Noah Goldstein via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 15:50:28 PDT 2024


Author: Noah Goldstein
Date: 2024-08-19T15:48:45-07:00
New Revision: 42ce62800dd24760ab6e400a3d5f898f11fe818a

URL: https://github.com/llvm/llvm-project/commit/42ce62800dd24760ab6e400a3d5f898f11fe818a
DIFF: https://github.com/llvm/llvm-project/commit/42ce62800dd24760ab6e400a3d5f898f11fe818a.diff

LOG: [ValueTracking] Handle incompatible types instead of asserting in `isKnownNonEqual`; NFC

Downstream hit this assert, since it doesn't really make any
difference, just change code to return false.

Added: 
    

Modified: 
    llvm/lib/Analysis/ValueTracking.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 9bd61f2996434a..173faa32a3878d 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -310,8 +310,9 @@ bool llvm::isKnownNonEqual(const Value *V1, const Value *V2,
                            const DataLayout &DL, AssumptionCache *AC,
                            const Instruction *CxtI, const DominatorTree *DT,
                            bool UseInstrInfo) {
-  assert(V1->getType() == V2->getType() &&
-         "Testing equality of non-equal types!");
+  // We don't support looking through casts.
+  if (V1 == V2 || V1->getType() != V2->getType())
+    return false;
   auto *FVTy = dyn_cast<FixedVectorType>(V1->getType());
   APInt DemandedElts =
       FVTy ? APInt::getAllOnes(FVTy->getNumElements()) : APInt(1, 1);


        


More information about the llvm-commits mailing list