[PATCH] D33107: AMDGPU/SI: Don't promote to vector if the load/store is volatile

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 12 13:44:28 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL302943: AMDGPU/SI: Don't promote to vector if the load/store is volatile. (authored by chfang).

Changed prior to commit:
  https://reviews.llvm.org/D33107?vs=98817&id=98838#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33107

Files:
  llvm/trunk/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
  llvm/trunk/test/CodeGen/AMDGPU/promote-alloca-volatile.ll


Index: llvm/trunk/test/CodeGen/AMDGPU/promote-alloca-volatile.ll
===================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/promote-alloca-volatile.ll
+++ llvm/trunk/test/CodeGen/AMDGPU/promote-alloca-volatile.ll
@@ -1,26 +1,26 @@
 ; RUN: opt -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-promote-alloca < %s | FileCheck %s
 
 ; CHECK-LABEL: @volatile_load(
-; CHECK: alloca [5 x i32]
+; CHECK: alloca [4 x i32]
 ; CHECK: load volatile i32, i32*
 define amdgpu_kernel void @volatile_load(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) {
 entry:
-  %stack = alloca [5 x i32], align 4
+  %stack = alloca [4 x i32], align 4
   %tmp = load i32, i32 addrspace(1)* %in, align 4
-  %arrayidx1 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %tmp
+  %arrayidx1 = getelementptr inbounds [4 x i32], [4 x i32]* %stack, i32 0, i32 %tmp
   %load = load volatile i32, i32* %arrayidx1
   store i32 %load, i32 addrspace(1)* %out
  ret void
 }
 
 ; CHECK-LABEL: @volatile_store(
-; CHECK: alloca [5 x i32]
+; CHECK: alloca [4 x i32]
 ; CHECK: store volatile i32 %tmp, i32*
 define amdgpu_kernel void @volatile_store(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) {
 entry:
-  %stack = alloca [5 x i32], align 4
+  %stack = alloca [4 x i32], align 4
   %tmp = load i32, i32 addrspace(1)* %in, align 4
-  %arrayidx1 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %tmp
+  %arrayidx1 = getelementptr inbounds [4 x i32], [4 x i32]* %stack, i32 0, i32 %tmp
   store volatile i32 %tmp, i32* %arrayidx1
  ret void
 }
Index: llvm/trunk/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
===================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
@@ -397,14 +397,17 @@
 // instructions.
 static bool canVectorizeInst(Instruction *Inst, User *User) {
   switch (Inst->getOpcode()) {
-  case Instruction::Load:
+  case Instruction::Load: {
+    LoadInst *LI = cast<LoadInst>(Inst);
+    return !LI->isVolatile();
+  }
   case Instruction::BitCast:
   case Instruction::AddrSpaceCast:
     return true;
   case Instruction::Store: {
     // Must be the stored pointer operand, not a stored value.
     StoreInst *SI = cast<StoreInst>(Inst);
-    return SI->getPointerOperand() == User;
+    return (SI->getPointerOperand() == User) && !SI->isVolatile();
   }
   default:
     return false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33107.98838.patch
Type: text/x-patch
Size: 2491 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170512/71aef5e2/attachment.bin>


More information about the llvm-commits mailing list