1 ; RUN: opt -passes=globalopt --mtriple=amdgcn-amd-amdhsa < %s -S | FileCheck %s
2 ; REQUIRES: amdgpu-registered-target
4 @gvar = internal unnamed_addr global i32 undef
5 @lvar = internal unnamed_addr addrspace(3) global i32 undef
7 ; Should optimize @gvar.
10 ; Negative test for AS(3). Skip shrink global to bool optimization.
11 ; CHECK: @lvar = internal unnamed_addr addrspace(3) global i32 undef
13 define void @test_global_var(i1 %i) {
14 ; CHECK-LABEL: @test_global_var(
15 ; CHECK: store volatile i32 10, i32* undef, align 4
18 br i1 %i, label %bb1, label %exit
20 store i32 10, i32* @gvar
23 %ld = load i32, i32* @gvar
24 store volatile i32 %ld, i32* undef
28 define void @test_lds_var(i1 %i) {
29 ; CHECK-LABEL: @test_lds_var(
30 ; CHECK: store i32 10, i32 addrspace(3)* @lvar, align 4
31 ; CHECK: [[LD:%.*]] = load i32, i32 addrspace(3)* @lvar, align 4
32 ; CHECK: store volatile i32 [[LD]], i32* undef, align 4
35 br i1 %i, label %bb1, label %exit
37 store i32 10, i32 addrspace(3)* @lvar
40 %ld = load i32, i32 addrspace(3)* @lvar
41 store volatile i32 %ld, i32* undef