[polly] r231592 - Add sign-extension during codegen of index expressions
Johannes Doerfert
doerfert at cs.uni-saarland.de
Sun Mar 8 08:18:51 PDT 2015
LGTM.
On 03/08, Tobias Grosser wrote:
> Author: grosser
> Date: Sun Mar 8 10:08:32 2015
> New Revision: 231592
>
> URL: http://llvm.org/viewvc/llvm-project?rev=231592&view=rev
> Log:
> Add sign-extension during codegen of index expressions
>
> When code generating array index expressions the types of the different
> components of the index expressions may not always match. We extend the type of
> the index expression (if possible) and assert otherwise.
>
> Added:
> polly/trunk/test/Isl/CodeGen/alias-check-multi-dim.ll
> Modified:
> polly/trunk/lib/CodeGen/IslExprBuilder.cpp
>
> Modified: polly/trunk/lib/CodeGen/IslExprBuilder.cpp
> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslExprBuilder.cpp?rev=231592&r1=231591&r2=231592&view=diff
> ==============================================================================
> --- polly/trunk/lib/CodeGen/IslExprBuilder.cpp (original)
> +++ polly/trunk/lib/CodeGen/IslExprBuilder.cpp Sun Mar 8 10:08:32 2015
> @@ -127,11 +127,17 @@ Value *IslExprBuilder::createAccessAddre
> assert(NextIndex->getType()->isIntegerTy() &&
> "Access index should be an integer");
>
> - if (!IndexOp)
> + if (!IndexOp) {
> IndexOp = NextIndex;
> - else
> + } else {
> + assert(NextIndex->getType()->getScalarSizeInBits() <=
> + IndexOp->getType()->getScalarSizeInBits() &&
> + "Truncating the index type may not be save");
> + NextIndex = Builder.CreateIntCast(NextIndex, IndexOp->getType(), true);
> +
> IndexOp =
> Builder.CreateAdd(IndexOp, NextIndex, "polly.access.add." + BaseName);
> + }
>
> // For every but the last dimension multiply the size, for the last
> // dimension we can exit the loop.
>
> Added: polly/trunk/test/Isl/CodeGen/alias-check-multi-dim.ll
> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/alias-check-multi-dim.ll?rev=231592&view=auto
> ==============================================================================
> --- polly/trunk/test/Isl/CodeGen/alias-check-multi-dim.ll (added)
> +++ polly/trunk/test/Isl/CodeGen/alias-check-multi-dim.ll Sun Mar 8 10:08:32 2015
> @@ -0,0 +1,25 @@
> +; RUN: opt %loadPolly -polly-codegen-isl -polly-delinearize -S < %s | FileCheck %s
> +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
> +target triple = "x86_64-unknown-linux-gnu"
> +
> +; CHECK: sext i32 %indvar.init to i64
> +
> +define void @foo(double* %A, double* %B, i32 %p, i32 %indvar.init) {
> +preheader:
> + br label %for.body
> +
> +for.body:
> + %indvar = phi i32 [ %indvar.next, %for.body ], [ %indvar.init, %preheader ]
> + %B.ptr0 = getelementptr inbounds double, double* %B, i64 0
> + %tmp1 = load double, double* %B.ptr0
> + %A.ptr = getelementptr inbounds double, double* %A, i64 0
> + store double undef, double* %A.ptr
> + %idxprom1329 = sext i32 %indvar to i64
> + %B.ptr1 = getelementptr inbounds double, double* %B, i64 %idxprom1329
> + store double 0.000000e+00, double* %B.ptr1
> + %indvar.next = add nsw i32 %indvar, %p
> + br i1 false, label %for.body, label %exit
> +
> +exit:
> + ret void
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
--
Johannes Doerfert
Researcher / PhD Student
Compiler Design Lab (Prof. Hack)
Saarland University, Computer Science
Building E1.3, Room 4.31
Tel. +49 (0)681 302-57521 : doerfert at cs.uni-saarland.de
Fax. +49 (0)681 302-3065 : http://www.cdl.uni-saarland.de/people/doerfert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 213 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150308/f041ac87/attachment.sig>
More information about the llvm-commits
mailing list