[PATCH] D108104: [LAA] Use getTypeSizeInBits for stride type size comparison

weiwei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 16 01:37:02 PDT 2021


wwei updated this revision to Diff 366568.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108104/new/

https://reviews.llvm.org/D108104

Files:
  llvm/lib/Analysis/LoopAccessAnalysis.cpp
  llvm/test/Transforms/LoopLoadElim/undef-stride.ll


Index: llvm/test/Transforms/LoopLoadElim/undef-stride.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/LoopLoadElim/undef-stride.ll
@@ -0,0 +1,33 @@
+; RUN: opt -enable-mem-access-versioning --loop-load-elim < %s -S | FileCheck %s
+; REQUIRES: asserts
+
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Make sure it does not crash with assert.
+define void @f([2 x [4 x i32]]* nocapture readonly %g) {
+
+for.cond.us.preheader:
+  br label %for.cond.us
+
+for.cond.us:                                      ; preds = %for.cond.cleanup.us-lcssa.us.us, %for.cond.us.preheader
+  %h.0.us = phi i8 [ %conv14.us, %for.cond.cleanup.us-lcssa.us.us ], [ 0, %for.cond.us.preheader ]
+  %idxprom.us = zext i8 %h.0.us to i64
+  %arrayidx4.us = getelementptr inbounds [2 x [4 x i32]], [2 x [4 x i32]]* %g, i64 0, i64 0, i64 %idxprom.us
+  br i1 undef, label %for.body.us.us.lr.ph, label %for.cond.cleanup.us-lcssa.us.us
+
+for.body.us.us.lr.ph:                             ; preds = %for.cond.us
+  br label %for.body.us.us
+
+for.body.us.us:                                   ; preds = %for.body.us.us, %for.body.us.us.lr.ph
+  %0 = load i32, i32* %arrayidx4.us, align 4
+  br i1 undef, label %for.body.us.us, label %for.cond1.us.us.for.cond.cleanup.us-lcssa.us.us_crit_edge
+
+for.cond1.us.us.for.cond.cleanup.us-lcssa.us.us_crit_edge: ; preds = %for.body.us.us
+  br label %for.cond.cleanup.us-lcssa.us.us
+
+for.cond.cleanup.us-lcssa.us.us:                  ; preds = %for.cond1.us.us.for.cond.cleanup.us-lcssa.us.us_crit_edge, %for.cond.us
+  %conv14.us = add i8 %h.0.us, undef
+  br label %for.cond.us
+}
+
Index: llvm/lib/Analysis/LoopAccessAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1405,8 +1405,8 @@
 
   const SCEV *CastedDist = &Dist;
   const SCEV *CastedProduct = Product;
-  uint64_t DistTypeSize = DL.getTypeAllocSize(Dist.getType());
-  uint64_t ProductTypeSize = DL.getTypeAllocSize(Product->getType());
+  uint64_t DistTypeSize = DL.getTypeSizeInBits(Dist.getType());
+  uint64_t ProductTypeSize = DL.getTypeSizeInBits(Product->getType());
 
   // The dependence distance can be positive/negative, so we sign extend Dist;
   // The multiplication of the absolute stride in bytes and the
@@ -2162,8 +2162,8 @@
   // The Stride can be positive/negative, so we sign extend Stride;
   // The backedgeTakenCount is non-negative, so we zero extend BETakenCount.
   const DataLayout &DL = TheLoop->getHeader()->getModule()->getDataLayout();
-  uint64_t StrideTypeSize = DL.getTypeAllocSize(StrideExpr->getType());
-  uint64_t BETypeSize = DL.getTypeAllocSize(BETakenCount->getType());
+  uint64_t StrideTypeSize = DL.getTypeSizeInBits(StrideExpr->getType());
+  uint64_t BETypeSize = DL.getTypeSizeInBits(BETakenCount->getType());
   const SCEV *CastedStride = StrideExpr;
   const SCEV *CastedBECount = BETakenCount;
   ScalarEvolution *SE = PSE->getSE();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108104.366568.patch
Type: text/x-patch
Size: 3109 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210816/844139de/attachment.bin>


More information about the llvm-commits mailing list