|
| 1 | +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 6 |
| 2 | +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx900 -O1 -emit-llvm -o - %s | FileCheck %s |
| 3 | + |
| 4 | +extern __attribute__((address_space(3))) unsigned char * ptr_as3; // local address space |
| 5 | +extern __attribute__((address_space(5))) unsigned char * ptr_as5; // private address space |
| 6 | + |
| 7 | +// CHECK-LABEL: define dso_local noundef ptr @_Z11get_ptr_as3b( |
| 8 | +// CHECK-SAME: i1 noundef zeroext [[V:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { |
| 9 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 10 | +// CHECK-NEXT: [[TMP0:%.*]] = load ptr addrspace(3), ptr addrspace(1) @ptr_as3, align 4 |
| 11 | +// CHECK-NEXT: [[TMP1:%.*]] = select i1 [[V]], ptr addrspace(3) [[TMP0]], ptr addrspace(3) addrspacecast (ptr null to ptr addrspace(3)) |
| 12 | +// CHECK-NEXT: [[TMP2:%.*]] = addrspacecast ptr addrspace(3) [[TMP1]] to ptr |
| 13 | +// CHECK-NEXT: ret ptr [[TMP2]] |
| 14 | +// |
| 15 | +unsigned char *get_ptr_as3(bool v) { |
| 16 | + return v ? ptr_as3 : nullptr; |
| 17 | +} |
| 18 | + |
| 19 | +// CHECK-LABEL: define dso_local noundef ptr @_Z20get_ptr_as3_with_tmpb( |
| 20 | +// CHECK-SAME: i1 noundef zeroext [[V:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 21 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 22 | +// CHECK-NEXT: [[TMP0:%.*]] = load ptr addrspace(3), ptr addrspace(1) @ptr_as3, align 4 |
| 23 | +// CHECK-NEXT: [[TMP1:%.*]] = select i1 [[V]], ptr addrspace(3) [[TMP0]], ptr addrspace(3) addrspacecast (ptr null to ptr addrspace(3)) |
| 24 | +// CHECK-NEXT: [[TMP2:%.*]] = addrspacecast ptr addrspace(3) [[TMP1]] to ptr |
| 25 | +// CHECK-NEXT: ret ptr [[TMP2]] |
| 26 | +// |
| 27 | +unsigned char *get_ptr_as3_with_tmp(bool v) { |
| 28 | + unsigned char *tmp = nullptr; |
| 29 | + return v ? ptr_as3 : tmp; |
| 30 | +} |
| 31 | + |
| 32 | +// CHECK-LABEL: define dso_local noundef ptr @_Z11get_ptr_as5b( |
| 33 | +// CHECK-SAME: i1 noundef zeroext [[V:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] { |
| 34 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 35 | +// CHECK-NEXT: [[TMP0:%.*]] = load ptr addrspace(5), ptr addrspace(1) @ptr_as5, align 4 |
| 36 | +// CHECK-NEXT: [[TMP1:%.*]] = select i1 [[V]], ptr addrspace(5) [[TMP0]], ptr addrspace(5) addrspacecast (ptr null to ptr addrspace(5)) |
| 37 | +// CHECK-NEXT: [[TMP2:%.*]] = addrspacecast ptr addrspace(5) [[TMP1]] to ptr |
| 38 | +// CHECK-NEXT: ret ptr [[TMP2]] |
| 39 | +// |
| 40 | +unsigned char *get_ptr_as5(bool v) { |
| 41 | + return v ? ptr_as5 : nullptr; |
| 42 | +} |
| 43 | + |
| 44 | +// CHECK-LABEL: define dso_local noundef ptr @_Z20get_ptr_as5_with_tmpb( |
| 45 | +// CHECK-SAME: i1 noundef zeroext [[V:%.*]]) local_unnamed_addr #[[ATTR1]] { |
| 46 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 47 | +// CHECK-NEXT: [[TMP0:%.*]] = load ptr addrspace(5), ptr addrspace(1) @ptr_as5, align 4 |
| 48 | +// CHECK-NEXT: [[TMP1:%.*]] = select i1 [[V]], ptr addrspace(5) [[TMP0]], ptr addrspace(5) addrspacecast (ptr null to ptr addrspace(5)) |
| 49 | +// CHECK-NEXT: [[TMP2:%.*]] = addrspacecast ptr addrspace(5) [[TMP1]] to ptr |
| 50 | +// CHECK-NEXT: ret ptr [[TMP2]] |
| 51 | +// |
| 52 | +unsigned char *get_ptr_as5_with_tmp(bool v) { |
| 53 | + unsigned char *tmp = nullptr; |
| 54 | + return v ? ptr_as5 : tmp; |
| 55 | +} |
0 commit comments