diff options
| author | Tobias Grosser <tobias@grosser.es> | 2015-01-13 19:37:59 +0000 |
|---|---|---|
| committer | Tobias Grosser <tobias@grosser.es> | 2015-01-13 19:37:59 +0000 |
| commit | c642e954023b38265d2c3df4ec3d9ba169b69048 (patch) | |
| tree | 56732abc5504ef4f0c19fa06de7c4fb927f2890a /polly/lib/CodeGen | |
| parent | 5d23224f21e8d60e896709c7f330ce25b9a8c739 (diff) | |
| download | bcm5719-llvm-c642e954023b38265d2c3df4ec3d9ba169b69048.tar.gz bcm5719-llvm-c642e954023b38265d2c3df4ec3d9ba169b69048.zip | |
Use types of matching size when generating multi-dimensional address expressions
This change ensures that the values that represent the array size of a
multi-dimensional access are correctly sign-extended when used to compute a
memory address used in the run-time alias check.
To make the test case more readable, we name the instructions that we generate.
llvm-svn: 225818
Diffstat (limited to 'polly/lib/CodeGen')
| -rw-r--r-- | polly/lib/CodeGen/IslExprBuilder.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/polly/lib/CodeGen/IslExprBuilder.cpp b/polly/lib/CodeGen/IslExprBuilder.cpp index d1e4e9667b1..4dd7ba3c9a1 100644 --- a/polly/lib/CodeGen/IslExprBuilder.cpp +++ b/polly/lib/CodeGen/IslExprBuilder.cpp @@ -127,7 +127,8 @@ Value *IslExprBuilder::createAccessAddress(isl_ast_expr *Expr) { if (!IndexOp) IndexOp = NextIndex; else - IndexOp = Builder.CreateAdd(IndexOp, NextIndex); + 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. @@ -135,9 +136,17 @@ Value *IslExprBuilder::createAccessAddress(isl_ast_expr *Expr) { break; const SCEV *DimSCEV = SAI->getDimensionSize(u - 1); - Value *DimSize = Expander.expandCodeFor(DimSCEV, IndexOp->getType(), + Value *DimSize = Expander.expandCodeFor(DimSCEV, DimSCEV->getType(), Builder.GetInsertPoint()); - IndexOp = Builder.CreateMul(IndexOp, DimSize); + + Type *Ty = getWidestType(DimSize->getType(), IndexOp->getType()); + + if (Ty != IndexOp->getType()) + IndexOp = Builder.CreateSExtOrTrunc(IndexOp, Ty, + "polly.access.sext." + BaseName); + + IndexOp = + Builder.CreateMul(IndexOp, DimSize, "polly.access.mul." + BaseName); } Access = Builder.CreateGEP(Base, IndexOp, "polly.access." + BaseName); |

