[polly] r251225 - ScopDetection: Always refuse multi-dimensional memory accesses with 'undef' in
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 25 01:40:38 PDT 2015
Author: grosser
Date: Sun Oct 25 03:40:38 2015
New Revision: 251225
URL: http://llvm.org/viewvc/llvm-project?rev=251225&view=rev
Log:
ScopDetection: Always refuse multi-dimensional memory accesses with 'undef' in
the size expression.
We previously only checked if the size expression is 'undef', but allowed size
expressions of the form 'undef * undef' by accident. After this change we now
require size expressions to be affine which implies no 'undef' appears anywhere
in the expression.
Added:
polly/trunk/test/ScopDetect/multidim-with-undef-size.ll
Modified:
polly/trunk/lib/Analysis/ScopDetection.cpp
Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=251225&r1=251224&r2=251225&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Sun Oct 25 03:40:38 2015
@@ -535,28 +535,25 @@ bool ScopDetection::hasAffineMemoryAcces
SE->findArrayDimensions(Terms, Shape->DelinearizedSizes,
Context.ElementSize[BasePointer]);
- if (!AllowNonAffine)
- for (const SCEV *DelinearizedSize : Shape->DelinearizedSizes) {
- if (auto *Unknown = dyn_cast<SCEVUnknown>(DelinearizedSize)) {
- auto *V = dyn_cast<Value>(Unknown->getValue());
- if (isa<UndefValue>(V)) {
- invalid<ReportDifferentArrayElementSize>(
- Context, /*Assert=*/true,
- Context.Accesses[BasePointer].front().first, BaseValue);
- return false;
- }
- if (auto *Load = dyn_cast<LoadInst>(V)) {
- if (Context.CurRegion.contains(Load) &&
- isHoistableLoad(Load, CurRegion, *LI, *SE))
- Context.RequiredILS.insert(Load);
- continue;
- }
+ for (const SCEV *DelinearizedSize : Shape->DelinearizedSizes) {
+ if (!isAffine(DelinearizedSize, Context, nullptr)) {
+ Shape->DelinearizedSizes.clear();
+ break;
+ }
+ if (auto *Unknown = dyn_cast<SCEVUnknown>(DelinearizedSize)) {
+ auto *V = dyn_cast<Value>(Unknown->getValue());
+ if (auto *Load = dyn_cast<LoadInst>(V)) {
+ if (Context.CurRegion.contains(Load) &&
+ isHoistableLoad(Load, CurRegion, *LI, *SE))
+ Context.RequiredILS.insert(Load);
+ continue;
}
- if (hasScalarDepsInsideRegion(DelinearizedSize, &CurRegion))
- invalid<ReportNonAffineAccess>(
- Context, /*Assert=*/true, DelinearizedSize,
- Context.Accesses[BasePointer].front().first, BaseValue);
}
+ if (hasScalarDepsInsideRegion(DelinearizedSize, &CurRegion))
+ invalid<ReportNonAffineAccess>(
+ Context, /*Assert=*/true, DelinearizedSize,
+ Context.Accesses[BasePointer].front().first, BaseValue);
+ }
// No array shape derived.
if (Shape->DelinearizedSizes.empty()) {
Added: polly/trunk/test/ScopDetect/multidim-with-undef-size.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopDetect/multidim-with-undef-size.ll?rev=251225&view=auto
==============================================================================
--- polly/trunk/test/ScopDetect/multidim-with-undef-size.ll (added)
+++ polly/trunk/test/ScopDetect/multidim-with-undef-size.ll Sun Oct 25 03:40:38 2015
@@ -0,0 +1,36 @@
+; RUN: opt %loadPolly -polly-detect -analyze < %s | FileCheck %s
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+; CHECK: Valid Region for Scop: bb14 => bb17
+
+; Make sure we do not detect the larger region bb14->bb19 that contains
+; a multi-dimensional memory access with a size of 'undef * undef'.
+
+define void @hoge(i8* %arg) {
+bb:
+ br label %bb6
+
+bb6: ; preds = %bb
+ %tmp = mul i64 undef, undef
+ %tmp7 = add i64 %tmp, undef
+ %tmp8 = add i64 %tmp7, 0
+ %tmp9 = add i64 %tmp8, 8
+ %tmp10 = sub i64 %tmp9, undef
+ %tmp11 = getelementptr i8, i8* %arg, i64 %tmp10
+ %tmp12 = getelementptr inbounds i8, i8* %tmp11, i64 4
+ %tmp13 = getelementptr inbounds i8, i8* %tmp12, i64 20
+ br label %bb14
+
+bb14: ; preds = %bb14, %bb6
+ %tmp15 = phi i32 [ %tmp16, %bb14 ], [ 2, %bb6 ]
+ %tmp16 = add nuw nsw i32 %tmp15, 1
+ br i1 false, label %bb14, label %bb17
+
+bb17: ; preds = %bb14
+ %tmp18 = bitcast i8* %tmp13 to i32*
+ store i32 undef, i32* %tmp18, align 4
+ br label %bb19
+
+bb19: ; preds = %bb17
+ unreachable
+}
More information about the llvm-commits
mailing list