summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2016-02-02 19:18:48 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2016-02-02 19:18:48 +0000
commit853a1fc6d9d433c9d68f6ecd04477bf120e0cb73 (patch)
tree759ce6fd2d138f143dfcd0ac6a24166f0c76858e /llvm/lib/Target
parentb0de6bad43ee35b0338c510d2bb1ba49eb233b7c (diff)
downloadbcm5719-llvm-853a1fc6d9d433c9d68f6ecd04477bf120e0cb73.tar.gz
bcm5719-llvm-853a1fc6d9d433c9d68f6ecd04477bf120e0cb73.zip
AMDGPU: Use inbounds when calculating workitem offset
When promoting allocas to LDS, we know we are indexing into a specific area just created, and the calculation will also never overflow. Also emit some of the muls as nsw nuw, because instcombine infers this already from the range metadata. I think putting this on the other adds and muls might be OK too, but I'm not 100% sure. llvm-svn: 259545
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
index 16676eceeee..cc09ced8f6e 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
@@ -485,17 +485,18 @@ void AMDGPUPromoteAlloca::visitAlloca(AllocaInst &I) {
Value *TIdY = getWorkitemID(Builder, 1);
Value *TIdZ = getWorkitemID(Builder, 2);
- Value *Tmp0 = Builder.CreateMul(TCntY, TCntZ);
+ Value *Tmp0 = Builder.CreateMul(TCntY, TCntZ, "", true, true);
Tmp0 = Builder.CreateMul(Tmp0, TIdX);
- Value *Tmp1 = Builder.CreateMul(TIdY, TCntZ);
+ Value *Tmp1 = Builder.CreateMul(TIdY, TCntZ, "", true, true);
Value *TID = Builder.CreateAdd(Tmp0, Tmp1);
TID = Builder.CreateAdd(TID, TIdZ);
- std::vector<Value*> Indices;
- Indices.push_back(Constant::getNullValue(Type::getInt32Ty(Mod->getContext())));
- Indices.push_back(TID);
+ Value *Indices[] = {
+ Constant::getNullValue(Type::getInt32Ty(Mod->getContext())),
+ TID
+ };
- Value *Offset = Builder.CreateGEP(GVTy, GV, Indices);
+ Value *Offset = Builder.CreateInBoundsGEP(GVTy, GV, Indices);
I.mutateType(Offset->getType());
I.replaceAllUsesWith(Offset);
I.eraseFromParent();
OpenPOWER on IntegriCloud