1 ; RUN: opt -passes=globalopt < %s -S | FileCheck %s
2 ; RUN: opt -passes=globalopt --mtriple=nvptx64 < %s -S | FileCheck %s --check-prefix=GPU
3 ; RUN: opt -passes=globalopt --mtriple=amdgcn < %s -S | FileCheck %s --check-prefix=GPU
4 ; REQUIRES: amdgpu-registered-target, nvptx-registered-target
6 ; Check that we don't try to set a global initializer for non AS(0) globals.
8 @g0 = internal global i16 undef
9 @g1 = internal addrspace(3) global i16 undef
10 @g2 = internal addrspace(1) global i16 undef
12 ; CHECK: internal unnamed_addr addrspace(3) global i16 undef
13 ; CHECK: internal unnamed_addr addrspace(1) global i16 undef
15 ; GPU: internal unnamed_addr addrspace(3) global i16 undef
19 store i16 3, ptr @g0, align 8
20 store i16 5, ptr addrspacecast (ptr addrspace(3) @g1 to ptr), align 8
21 store i16 7, ptr addrspacecast (ptr addrspace(1) @g2 to ptr), align 8
26 %gep = getelementptr i8, ptr @g0, i64 1
27 %r = load i8, ptr %gep
31 %ac = addrspacecast ptr addrspace(3) @g1 to ptr
32 %gep = getelementptr i8, ptr %ac, i64 1
33 %r = load i8, ptr %gep
37 %ac = addrspacecast ptr addrspace(1) @g2 to ptr
38 %gep = getelementptr i8, ptr %ac, i64 1
39 %r = load i8, ptr %gep