1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -run-pass=machine-cse -o - %s | FileCheck %s
3 # RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -run-pass=machine-cse -o - %s | FileCheck %s
6 define void @commute_instruction_subreg_target_flag() { ret void }
7 define void @commute_target_flag_frame_index() { ret void }
8 define void @commute_target_flag_global() { ret void }
9 define void @commute_target_flag_global_offset() { ret void }
10 define void @commute_target_flag_global_offset_mismatch() { ret void }
13 @gv = external addrspace(1) global i32
17 # Make sure the subreg index is cleared when commuting a register and immediate.
20 name: commute_instruction_subreg_target_flag
21 tracksRegLiveness: true
26 ; CHECK-LABEL: name: commute_instruction_subreg_target_flag
27 ; CHECK: liveins: $vgpr0_vgpr1
29 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
30 ; CHECK-NEXT: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 [[COPY]].sub1, 64, 0, implicit $exec
31 ; CHECK-NEXT: S_ENDPGM 0, implicit [[V_ADD_U32_e64_]], implicit [[V_ADD_U32_e64_]]
32 %0:vreg_64 = COPY $vgpr0_vgpr1
33 %1:vgpr_32 = V_ADD_U32_e64 %0.sub1, 64, 0, implicit $exec
34 %2:vgpr_32 = V_ADD_U32_e64 64, %0.sub1, 0, implicit $exec
35 S_ENDPGM 0, implicit %1, implicit %2
39 # FIXME: Why doesn't this CSE?
41 name: commute_target_flag_frame_index
42 tracksRegLiveness: true
44 - { id: 0, type: default, offset: 0, size: 4, alignment: 4 }
49 ; CHECK-LABEL: name: commute_target_flag_frame_index
50 ; CHECK: liveins: $vgpr0_vgpr1
52 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
53 ; CHECK-NEXT: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 %stack.0, [[COPY]].sub0, 0, implicit $exec
54 ; CHECK-NEXT: S_ENDPGM 0, implicit [[V_ADD_U32_e64_]], implicit [[V_ADD_U32_e64_]]
55 %0:vreg_64 = COPY $vgpr0_vgpr1
56 %1:vgpr_32 = V_ADD_U32_e64 %0.sub0, %stack.0, 0, implicit $exec
57 %2:vgpr_32 = V_ADD_U32_e64 %stack.0, %0.sub0, 0, implicit $exec
58 S_ENDPGM 0, implicit %1, implicit %2
62 # FIXME: Handle commuting global variables
64 name: commute_target_flag_global
65 tracksRegLiveness: true
70 ; CHECK-LABEL: name: commute_target_flag_global
71 ; CHECK: liveins: $sgpr0_sgpr1
73 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $sgpr0_sgpr1
74 ; CHECK-NEXT: [[S_ADD_U32_:%[0-9]+]]:sreg_32 = S_ADD_U32 [[COPY]].sub0, target-flags(amdgpu-rel32-lo) @func, implicit-def dead $scc
75 ; CHECK-NEXT: S_ENDPGM 0, implicit [[S_ADD_U32_]], implicit [[S_ADD_U32_]]
76 %0:sreg_64 = COPY $sgpr0_sgpr1
77 %1:sreg_32 = S_ADD_U32 %0.sub0, target-flags(amdgpu-rel32-lo) @func, implicit-def dead $scc
78 %2:sreg_32 = S_ADD_U32 target-flags(amdgpu-rel32-lo) @func, %0.sub0, implicit-def dead $scc
79 S_ENDPGM 0, implicit %1, implicit %2
84 name: commute_target_flag_global_offset
85 tracksRegLiveness: true
90 ; CHECK-LABEL: name: commute_target_flag_global_offset
91 ; CHECK: liveins: $sgpr0_sgpr1
93 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $sgpr0_sgpr1
94 ; CHECK-NEXT: [[S_ADD_U32_:%[0-9]+]]:sreg_32 = S_ADD_U32 [[COPY]].sub0, target-flags(amdgpu-rel32-lo) @gv + 4, implicit-def dead $scc
95 ; CHECK-NEXT: S_ENDPGM 0, implicit [[S_ADD_U32_]], implicit [[S_ADD_U32_]]
96 %0:sreg_64 = COPY $sgpr0_sgpr1
97 %1:sreg_32 = S_ADD_U32 %0.sub0, target-flags(amdgpu-rel32-lo) @gv + 4, implicit-def dead $scc
98 %2:sreg_32 = S_ADD_U32 target-flags(amdgpu-rel32-lo) @gv + 4, %0.sub0, implicit-def dead $scc
99 S_ENDPGM 0, implicit %1, implicit %2
104 name: commute_target_flag_global_offset_mismatch
105 tracksRegLiveness: true
108 liveins: $sgpr0_sgpr1
110 ; CHECK-LABEL: name: commute_target_flag_global_offset_mismatch
111 ; CHECK: liveins: $sgpr0_sgpr1
113 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $sgpr0_sgpr1
114 ; CHECK-NEXT: [[S_ADD_U32_:%[0-9]+]]:sreg_32 = S_ADD_U32 [[COPY]].sub0, target-flags(amdgpu-rel32-lo) @gv + 4, implicit-def dead $scc
115 ; CHECK-NEXT: [[S_ADD_U32_1:%[0-9]+]]:sreg_32 = S_ADD_U32 target-flags(amdgpu-rel32-lo) @gv + 8, [[COPY]].sub0, implicit-def dead $scc
116 ; CHECK-NEXT: S_ENDPGM 0, implicit [[S_ADD_U32_]], implicit [[S_ADD_U32_1]]
117 %0:sreg_64 = COPY $sgpr0_sgpr1
118 %1:sreg_32 = S_ADD_U32 %0.sub0, target-flags(amdgpu-rel32-lo) @gv + 4, implicit-def dead $scc
119 %2:sreg_32 = S_ADD_U32 target-flags(amdgpu-rel32-lo) @gv + 8, %0.sub0, implicit-def dead $scc
120 S_ENDPGM 0, implicit %1, implicit %2