[LAA] Fix latent missing check bug when mixing scalable and non-scalabe strides
authorPhilip Reames <preames@rivosinc.com>
Wed, 20 Jul 2022 18:54:05 +0000 (11:54 -0700)
committerPhilip Reames <listmail@philipreames.com>
Wed, 20 Jul 2022 18:56:45 +0000 (11:56 -0700)
Noticed via inspection; to my knowledge, impossible to hit today.  In theory, we could have a fixed stride check be analyzed, then a scalable one.  With the old code, the scalable one would be silently dropped, and the runtime guard would go ahead with only the fixed one.  This would be a miscompile.

llvm/lib/Analysis/LoopAccessAnalysis.cpp

index f7f0dc4dcb1d2aef9dba8d4ecd5e47ce077f684a..0bc2e761d080f893d77d7c2465a3871badfa5ca7 100644 (file)
@@ -293,8 +293,10 @@ void RuntimePointerChecking::tryToCreateDiffCheck(
       DC.getInstructionsForAccess(Sink->PointerValue, Sink->IsWritePtr);
   Type *SrcTy = getLoadStoreType(SrcInsts[0]);
   Type *DstTy = getLoadStoreType(SinkInsts[0]);
-  if (isa<ScalableVectorType>(SrcTy) || isa<ScalableVectorType>(DstTy))
+  if (isa<ScalableVectorType>(SrcTy) || isa<ScalableVectorType>(DstTy)) {
+    CanUseDiffCheck = false;
     return;
+  }
   unsigned AllocSize =
       std::max(DL.getTypeAllocSize(SrcTy), DL.getTypeAllocSize(DstTy));
   IntegerType *IntTy =