llvm.org GIT mirror llvm / ed4c807
AMDGPU/SI: Don't promote to vector if the load/store is volatile. Summary: We should not change volatile loads/stores in promoting alloca to vector. Reviewers: arsenm Differential Revision: http://reviews.llvm.org/D33107 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302943 91177308-0d34-0410-b5e6-96231b3b80d8 Changpeng Fang 3 years ago
2 changed file(s) with 11 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
396396 // instructions.
397397 static bool canVectorizeInst(Instruction *Inst, User *User) {
398398 switch (Inst->getOpcode()) {
399 case Instruction::Load:
399 case Instruction::Load: {
400 LoadInst *LI = cast(Inst);
401 return !LI->isVolatile();
402 }
400403 case Instruction::BitCast:
401404 case Instruction::AddrSpaceCast:
402405 return true;
403406 case Instruction::Store: {
404407 // Must be the stored pointer operand, not a stored value.
405408 StoreInst *SI = cast(Inst);
406 return SI->getPointerOperand() == User;
409 return (SI->getPointerOperand() == User) && !SI->isVolatile();
407410 }
408411 default:
409412 return false;
0 ; RUN: opt -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-promote-alloca < %s | FileCheck %s
11
22 ; CHECK-LABEL: @volatile_load(
3 ; CHECK: alloca [5 x i32]
3 ; CHECK: alloca [4 x i32]
44 ; CHECK: load volatile i32, i32*
55 define amdgpu_kernel void @volatile_load(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) {
66 entry:
7 %stack = alloca [5 x i32], align 4
7 %stack = alloca [4 x i32], align 4
88 %tmp = load i32, i32 addrspace(1)* %in, align 4
9 %arrayidx1 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %tmp
9 %arrayidx1 = getelementptr inbounds [4 x i32], [4 x i32]* %stack, i32 0, i32 %tmp
1010 %load = load volatile i32, i32* %arrayidx1
1111 store i32 %load, i32 addrspace(1)* %out
1212 ret void
1313 }
1414
1515 ; CHECK-LABEL: @volatile_store(
16 ; CHECK: alloca [5 x i32]
16 ; CHECK: alloca [4 x i32]
1717 ; CHECK: store volatile i32 %tmp, i32*
1818 define amdgpu_kernel void @volatile_store(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) {
1919 entry:
20 %stack = alloca [5 x i32], align 4
20 %stack = alloca [4 x i32], align 4
2121 %tmp = load i32, i32 addrspace(1)* %in, align 4
22 %arrayidx1 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %tmp
22 %arrayidx1 = getelementptr inbounds [4 x i32], [4 x i32]* %stack, i32 0, i32 %tmp
2323 store volatile i32 %tmp, i32* %arrayidx1
2424 ret void
2525 }