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, ptr undef, align 4
18 br i1 %i, label %bb1, label %exit
20 store i32 10, ptr @gvar
23 %ld = load i32, ptr @gvar
24 store volatile i32 %ld, ptr undef
28 define void @test_lds_var(i1 %i) {
29 ; CHECK-LABEL: @test_lds_var(
30 ; CHECK: store i32 10, ptr addrspace(3) @lvar, align 4
31 ; CHECK: [[LD:%.*]] = load i32, ptr addrspace(3) @lvar, align 4
32 ; CHECK: store volatile i32 [[LD]], ptr undef, align 4
35 br i1 %i, label %bb1, label %exit
37 store i32 10, ptr addrspace(3) @lvar
40 %ld = load i32, ptr addrspace(3) @lvar
41 store volatile i32 %ld, ptr undef