diff options
| author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2016-05-18 15:57:21 +0000 |
|---|---|---|
| committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2016-05-18 15:57:21 +0000 |
| commit | 891fccc0c178f6b6cc6b024945d8311cb21d864b (patch) | |
| tree | ac2f04f7cffc1860f2d4810a49693fc4d10f7f55 /llvm/test/CodeGen | |
| parent | 71fa1f375e5aef9a0bde52c60f91b21553411329 (diff) | |
| download | bcm5719-llvm-891fccc0c178f6b6cc6b024945d8311cb21d864b.tar.gz bcm5719-llvm-891fccc0c178f6b6cc6b024945d8311cb21d864b.zip | |
AMDGPU: Handle alloca promoting with null operands
If the second pointer in a multi-pointer instruction is
a constant, we can replace the type.
llvm-svn: 269945
Diffstat (limited to 'llvm/test/CodeGen')
3 files changed, 91 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/AMDGPU/promote-alloca-to-lds-icmp.ll b/llvm/test/CodeGen/AMDGPU/promote-alloca-to-lds-icmp.ll index 206e63f1cfd..857e547aa03 100644 --- a/llvm/test/CodeGen/AMDGPU/promote-alloca-to-lds-icmp.ll +++ b/llvm/test/CodeGen/AMDGPU/promote-alloca-to-lds-icmp.ll @@ -18,6 +18,32 @@ define void @lds_promoted_alloca_icmp_same_derived_pointer(i32 addrspace(1)* %ou ret void } +; CHECK-LABEL: @lds_promoted_alloca_icmp_null_rhs( +; CHECK: [[ARRAYGEP:%[0-9]+]] = getelementptr inbounds [256 x [16 x i32]], [256 x [16 x i32]] addrspace(3)* @lds_promoted_alloca_icmp_null_rhs.alloca, i32 0, i32 %{{[0-9]+}} +; CHECK: %ptr0 = getelementptr inbounds [16 x i32], [16 x i32] addrspace(3)* [[ARRAYGEP]], i32 0, i32 %a +; CHECK: %cmp = icmp eq i32 addrspace(3)* %ptr0, null +define void @lds_promoted_alloca_icmp_null_rhs(i32 addrspace(1)* %out, i32 %a, i32 %b) #0 { + %alloca = alloca [16 x i32], align 4 + %ptr0 = getelementptr inbounds [16 x i32], [16 x i32]* %alloca, i32 0, i32 %a + %cmp = icmp eq i32* %ptr0, null + %zext = zext i1 %cmp to i32 + store volatile i32 %zext, i32 addrspace(1)* %out + ret void +} + +; CHECK-LABEL: @lds_promoted_alloca_icmp_null_lhs( +; CHECK: [[ARRAYGEP:%[0-9]+]] = getelementptr inbounds [256 x [16 x i32]], [256 x [16 x i32]] addrspace(3)* @lds_promoted_alloca_icmp_null_lhs.alloca, i32 0, i32 %{{[0-9]+}} +; CHECK: %ptr0 = getelementptr inbounds [16 x i32], [16 x i32] addrspace(3)* [[ARRAYGEP]], i32 0, i32 %a +; CHECK: %cmp = icmp eq i32 addrspace(3)* null, %ptr0 +define void @lds_promoted_alloca_icmp_null_lhs(i32 addrspace(1)* %out, i32 %a, i32 %b) #0 { + %alloca = alloca [16 x i32], align 4 + %ptr0 = getelementptr inbounds [16 x i32], [16 x i32]* %alloca, i32 0, i32 %a + %cmp = icmp eq i32* null, %ptr0 + %zext = zext i1 %cmp to i32 + store volatile i32 %zext, i32 addrspace(1)* %out + ret void +} + ; CHECK-LABEL: @lds_promoted_alloca_icmp_unknown_ptr( ; CHECK: %alloca = alloca [16 x i32], align 4 ; CHECK: %ptr0 = getelementptr inbounds [16 x i32], [16 x i32]* %alloca, i32 0, i32 %a diff --git a/llvm/test/CodeGen/AMDGPU/promote-alloca-to-lds-phi.ll b/llvm/test/CodeGen/AMDGPU/promote-alloca-to-lds-phi.ll index c3c215a5962..a0ad564a6c8 100644 --- a/llvm/test/CodeGen/AMDGPU/promote-alloca-to-lds-phi.ll +++ b/llvm/test/CodeGen/AMDGPU/promote-alloca-to-lds-phi.ll @@ -32,6 +32,40 @@ endif: ret void } +; CHECK-LABEL: @branch_ptr_phi_alloca_null_0( +; CHECK: %phi.ptr = phi i32 addrspace(3)* [ %arrayidx0, %if ], [ null, %entry ] +define void @branch_ptr_phi_alloca_null_0(i32 %a, i32 %b) #0 { +entry: + %alloca = alloca [64 x i32], align 4 + br i1 undef, label %if, label %endif + +if: + %arrayidx0 = getelementptr inbounds [64 x i32], [64 x i32]* %alloca, i32 0, i32 %a + br label %endif + +endif: + %phi.ptr = phi i32* [ %arrayidx0, %if ], [ null, %entry ] + store i32 0, i32* %phi.ptr, align 4 + ret void +} + +; CHECK-LABEL: @branch_ptr_phi_alloca_null_1( +; CHECK: %phi.ptr = phi i32 addrspace(3)* [ null, %entry ], [ %arrayidx0, %if ] +define void @branch_ptr_phi_alloca_null_1(i32 %a, i32 %b) #0 { +entry: + %alloca = alloca [64 x i32], align 4 + br i1 undef, label %if, label %endif + +if: + %arrayidx0 = getelementptr inbounds [64 x i32], [64 x i32]* %alloca, i32 0, i32 %a + br label %endif + +endif: + %phi.ptr = phi i32* [ null, %entry ], [ %arrayidx0, %if ] + store i32 0, i32* %phi.ptr, align 4 + ret void +} + ; CHECK-LABEL: @one_phi_value( ; CHECK: getelementptr inbounds [256 x [64 x i32]], [256 x [64 x i32]] addrspace(3)* @one_phi_value.alloca, i32 0, i32 %14 ; CHECK: %arrayidx0 = getelementptr inbounds [64 x i32], [64 x i32] addrspace(3)* %{{[0-9]+}}, i32 0, i32 %a diff --git a/llvm/test/CodeGen/AMDGPU/promote-alloca-to-lds-select.ll b/llvm/test/CodeGen/AMDGPU/promote-alloca-to-lds-select.ll index fd411de0198..bb13adb1985 100644 --- a/llvm/test/CodeGen/AMDGPU/promote-alloca-to-lds-select.ll +++ b/llvm/test/CodeGen/AMDGPU/promote-alloca-to-lds-select.ll @@ -99,4 +99,35 @@ bb2: ret void } +; CHECK-LABEL: @select_null_rhs( +; CHECK-NOT: alloca +; CHECK: select i1 %tmp2, double addrspace(3)* %{{[0-9]+}}, double addrspace(3)* null +define void @select_null_rhs(double addrspace(1)* nocapture %arg, i32 %arg1) #1 { +bb: + %tmp = alloca double, align 8 + store double 0.000000e+00, double* %tmp, align 8 + %tmp2 = icmp eq i32 %arg1, 0 + %tmp3 = select i1 %tmp2, double* %tmp, double* null + store double 1.000000e+00, double* %tmp3, align 8 + %tmp4 = load double, double* %tmp, align 8 + store double %tmp4, double addrspace(1)* %arg + ret void +} + +; CHECK-LABEL: @select_null_lhs( +; CHECK-NOT: alloca +; CHECK: select i1 %tmp2, double addrspace(3)* null, double addrspace(3)* %{{[0-9]+}} +define void @select_null_lhs(double addrspace(1)* nocapture %arg, i32 %arg1) #1 { +bb: + %tmp = alloca double, align 8 + store double 0.000000e+00, double* %tmp, align 8 + %tmp2 = icmp eq i32 %arg1, 0 + %tmp3 = select i1 %tmp2, double* null, double* %tmp + store double 1.000000e+00, double* %tmp3, align 8 + %tmp4 = load double, double* %tmp, align 8 + store double %tmp4, double addrspace(1)* %arg + ret void +} + attributes #0 = { norecurse nounwind "amdgpu-max-waves-per-eu"="1" } +attributes #1 = { norecurse nounwind }
\ No newline at end of file |

