mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-27 13:40:30 +00:00
AMDGPU: Fix promote alloca for pointer loads
If the load has a pointer type, we don't want to change its type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270000 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9dbb32236a
commit
44aaff08ed
@ -552,6 +552,13 @@ bool AMDGPUPromoteAlloca::collectUsesWithPtrTypes(
|
||||
if (UseInst->getOpcode() == Instruction::PtrToInt)
|
||||
return false;
|
||||
|
||||
if (LoadInst *LI = dyn_cast_or_null<LoadInst>(UseInst)) {
|
||||
if (LI->isVolatile())
|
||||
return false;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (StoreInst *SI = dyn_cast<StoreInst>(UseInst)) {
|
||||
if (SI->isVolatile())
|
||||
return false;
|
||||
@ -559,9 +566,6 @@ bool AMDGPUPromoteAlloca::collectUsesWithPtrTypes(
|
||||
// Reject if the stored value is not the pointer operand.
|
||||
if (SI->getPointerOperand() != Val)
|
||||
return false;
|
||||
} else if (LoadInst *LI = dyn_cast_or_null<LoadInst>(UseInst)) {
|
||||
if (LI->isVolatile())
|
||||
return false;
|
||||
} else if (AtomicRMWInst *RMW = dyn_cast_or_null<AtomicRMWInst>(UseInst)) {
|
||||
if (RMW->isVolatile())
|
||||
return false;
|
||||
|
@ -1,14 +1,16 @@
|
||||
; RUN: llc -march=r600 -mcpu=cypress < %s | FileCheck %s -check-prefix=R600 -check-prefix=FUNC
|
||||
; RUN: llc -show-mc-encoding -mattr=+promote-alloca -verify-machineinstrs -march=amdgcn < %s | FileCheck %s -check-prefix=SI-PROMOTE -check-prefix=SI -check-prefix=FUNC
|
||||
; RUN: llc -show-mc-encoding -mattr=+promote-alloca -verify-machineinstrs -mtriple=amdgcn--amdhsa -mcpu=kaveri < %s | FileCheck %s -check-prefix=SI-PROMOTE -check-prefix=SI -check-prefix=FUNC -check-prefix=HSA-PROMOTE
|
||||
; RUN: llc -show-mc-encoding -mattr=-promote-alloca -verify-machineinstrs -march=amdgcn < %s | FileCheck %s -check-prefix=SI-ALLOCA -check-prefix=SI -check-prefix=FUNC
|
||||
; RUN: llc -show-mc-encoding -mattr=-promote-alloca -verify-machineinstrs -mtriple=amdgcn-amdhsa -mcpu=kaveri < %s | FileCheck %s -check-prefix=SI-ALLOCA -check-prefix=SI -check-prefix=FUNC -check-prefix=HSA-ALLOCA
|
||||
; RUN: llc -show-mc-encoding -mattr=+promote-alloca -verify-machineinstrs -march=amdgcn -mcpu=tonga < %s | FileCheck %s -check-prefix=SI-PROMOTE -check-prefix=SI -check-prefix=FUNC
|
||||
; RUN: llc -show-mc-encoding -mattr=-promote-alloca -verify-machineinstrs -march=amdgcn -mcpu=tonga < %s | FileCheck %s -check-prefix=SI-ALLOCA -check-prefix=SI -check-prefix=FUNC
|
||||
; RUN: llc -show-mc-encoding -mattr=+promote-alloca -verify-machineinstrs -mtriple=amdgcn-amdhsa -march=amdgcn -mcpu=tonga < %s | FileCheck %s -check-prefix=SI-PROMOTE -check-prefix=SI -check-prefix=FUNC
|
||||
; RUN: llc -show-mc-encoding -mattr=-promote-alloca -verify-machineinstrs -mtriple=amdgcn-amdhsa -march=amdgcn -mcpu=tonga < %s | FileCheck %s -check-prefix=SI-ALLOCA -check-prefix=SI -check-prefix=FUNC
|
||||
|
||||
; RUN: opt -S -mtriple=amdgcn-unknown-amdhsa -mcpu=kaveri -amdgpu-promote-alloca < %s | FileCheck -check-prefix=HSAOPT -check-prefix=OPT %s
|
||||
; RUN: opt -S -mtriple=amdgcn-unknown-unknown -mcpu=kaveri -amdgpu-promote-alloca < %s | FileCheck -check-prefix=NOHSAOPT -check-prefix=OPT %s
|
||||
|
||||
; RUN: llc -march=r600 -mcpu=cypress < %s | FileCheck %s -check-prefix=R600 -check-prefix=FUNC
|
||||
|
||||
|
||||
; HSAOPT: @mova_same_clause.stack = internal unnamed_addr addrspace(3) global [256 x [5 x i32]] undef, align 4
|
||||
; HSAOPT: @high_alignment.stack = internal unnamed_addr addrspace(3) global [256 x [8 x i32]] undef, align 16
|
||||
|
||||
@ -396,6 +398,25 @@ define void @ptrtoint(i32 addrspace(1)* %out, i32 %a, i32 %b) #0 {
|
||||
ret void
|
||||
}
|
||||
|
||||
; OPT-LABEL: @pointer_typed_alloca(
|
||||
; OPT: getelementptr inbounds [256 x i32 addrspace(1)*], [256 x i32 addrspace(1)*] addrspace(3)* @pointer_typed_alloca.A.addr, i32 0, i32 %{{[0-9]+}}
|
||||
; OPT: load i32 addrspace(1)*, i32 addrspace(1)* addrspace(3)* %{{[0-9]+}}, align 4
|
||||
define void @pointer_typed_alloca(i32 addrspace(1)* %A) {
|
||||
entry:
|
||||
%A.addr = alloca i32 addrspace(1)*, align 4
|
||||
store i32 addrspace(1)* %A, i32 addrspace(1)** %A.addr, align 4
|
||||
%ld0 = load i32 addrspace(1)*, i32 addrspace(1)** %A.addr, align 4
|
||||
%arrayidx = getelementptr inbounds i32, i32 addrspace(1)* %ld0, i32 0
|
||||
store i32 1, i32 addrspace(1)* %arrayidx, align 4
|
||||
%ld1 = load i32 addrspace(1)*, i32 addrspace(1)** %A.addr, align 4
|
||||
%arrayidx1 = getelementptr inbounds i32, i32 addrspace(1)* %ld1, i32 1
|
||||
store i32 2, i32 addrspace(1)* %arrayidx1, align 4
|
||||
%ld2 = load i32 addrspace(1)*, i32 addrspace(1)** %A.addr, align 4
|
||||
%arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %ld2, i32 2
|
||||
store i32 3, i32 addrspace(1)* %arrayidx2, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; HSAOPT: !0 = !{}
|
||||
; HSAOPT: !1 = !{i32 0, i32 2048}
|
||||
|
||||
|
@ -24,3 +24,22 @@ entry:
|
||||
store volatile i32 %tmp, i32* %arrayidx1
|
||||
ret void
|
||||
}
|
||||
|
||||
; Has on OK non-volatile user but also a volatile user
|
||||
; CHECK-LABEL: @volatile_and_non_volatile_load(
|
||||
; CHECK: alloca double
|
||||
; CHECK: load double
|
||||
; CHECK: load volatile double
|
||||
define void @volatile_and_non_volatile_load(double addrspace(1)* nocapture %arg, i32 %arg1) #0 {
|
||||
bb:
|
||||
%tmp = alloca double, align 8
|
||||
store double 0.000000e+00, double* %tmp, align 8
|
||||
|
||||
%tmp4 = load double, double* %tmp, align 8
|
||||
%tmp5 = load volatile double, double* %tmp, align 8
|
||||
|
||||
store double %tmp4, double addrspace(1)* %arg
|
||||
ret void
|
||||
}
|
||||
|
||||
attributes #0 = { nounwind }
|
||||
|
Loading…
Reference in New Issue
Block a user