Recommit r310809 with a fix for the spill problem
[llvm-core.git] / test / CodeGen / AMDGPU / vccz-corrupt-bug-workaround.mir
blob54991d3d953cdeffdb6424c9801a969656466012
1 # RUN: llc -run-pass si-insert-waits -march=amdgcn -mcpu=tahiti -o - %s | FileCheck %s
2 --- |
4   define amdgpu_kernel void @vccz_corrupt_workaround(float %cond, i32 addrspace(1)* %out) #0 {
5   entry:
6     %cmp0 = fcmp oeq float %cond, 0.000000e+00
7     br i1 %cmp0, label %if, label %else, !structurizecfg.uniform !0, !amdgpu.uniform !0
9   else:                                             ; preds = %entry
10     store volatile i32 100, i32 addrspace(1)* undef
11     br label %done, !structurizecfg.uniform !0
13   if:                                               ; preds = %entry
14     store volatile i32 9, i32 addrspace(1)* undef
15     br label %done, !structurizecfg.uniform !0
17   done:                                             ; preds = %if, %else
18     %value = phi i32 [ 0, %if ], [ 1, %else ]
19     store i32 %value, i32 addrspace(1)* %out
20     ret void
21   }
23   define amdgpu_kernel void @vccz_corrupt_undef_vcc(float %cond, i32 addrspace(1)* %out) #0 {
24   entry:
25     br i1 undef, label %if, label %else, !structurizecfg.uniform !0, !amdgpu.uniform !0
27   else:                                             ; preds = %entry
28     store volatile i32 100, i32 addrspace(1)* undef
29     br label %done, !structurizecfg.uniform !0
31   if:                                               ; preds = %entry
32     store volatile i32 9, i32 addrspace(1)* undef
33     br label %done, !structurizecfg.uniform !0
35   done:                                             ; preds = %if, %else
36     %value = phi i32 [ 0, %if ], [ 1, %else ]
37     store i32 %value, i32 addrspace(1)* %out
38     ret void
39   }
41   attributes #0 = { nounwind }
42   attributes #1 = { readnone }
44   !0 = !{}
46 ...
47 ---
48 # CHECK-LABEL: name: vccz_corrupt_workaround
49 # CHECK: %vcc = V_CMP_EQ_F32
50 # CHECK-NEXT: %vcc = S_MOV_B64 %vcc
51 # CHECK-NEXT: S_CBRANCH_VCCZ %bb.2.else, implicit killed %vcc
53 name:            vccz_corrupt_workaround
54 alignment:       0
55 exposesReturnsTwice: false
56 legalized:       false
57 regBankSelected: false
58 selected:        false
59 tracksRegLiveness: true
60 liveins:
61   - { reg: '%sgpr0_sgpr1' }
62 frameInfo:
63   isFrameAddressTaken: false
64   isReturnAddressTaken: false
65   hasStackMap:     false
66   hasPatchPoint:   false
67   stackSize:       0
68   offsetAdjustment: 0
69   maxAlignment:    0
70   adjustsStack:    false
71   hasCalls:        false
72   maxCallFrameSize: 0
73   hasOpaqueSPAdjustment: false
74   hasVAStart:      false
75   hasMustTailInVarArgFunc: false
76 body:             |
77   bb.0.entry:
78     liveins: %sgpr0_sgpr1
80     %sgpr2 = S_LOAD_DWORD_IMM %sgpr0_sgpr1, 9, 0 :: (non-temporal dereferenceable invariant load 4 from `float addrspace(2)* undef`)
81     %sgpr0_sgpr1 = S_LOAD_DWORDX2_IMM killed %sgpr0_sgpr1, 11, 0 :: (non-temporal dereferenceable invariant load 8 from `i64 addrspace(2)* undef`)
82     %sgpr7 = S_MOV_B32 61440
83     %sgpr6 = S_MOV_B32 -1
84     %vcc = V_CMP_EQ_F32_e64 0, 0, 0, %sgpr2, 0, implicit %exec
85     S_CBRANCH_VCCZ %bb.1.else, implicit killed %vcc
87   bb.2.if:
88     liveins: %sgpr6, %sgpr7, %sgpr0_sgpr1_sgpr2_sgpr3:0x00000003
90     %vgpr0 = V_MOV_B32_e32 9, implicit %exec
91     BUFFER_STORE_DWORD_OFFSET killed %vgpr0, killed %sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, 0, implicit %exec :: (volatile store 4 into `i32 addrspace(1)* undef`)
92     %vgpr0 = V_MOV_B32_e32 0, implicit %exec
93     S_BRANCH %bb.3.done
95   bb.1.else:
96     liveins: %sgpr6, %sgpr7, %sgpr0_sgpr1_sgpr2_sgpr3:0x00000003
98     %vgpr0 = V_MOV_B32_e32 100, implicit %exec
99     BUFFER_STORE_DWORD_OFFSET killed %vgpr0, killed %sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, 0, implicit %exec :: (volatile store 4 into `i32 addrspace(1)* undef`)
100     %vgpr0 = V_MOV_B32_e32 1, implicit %exec
102   bb.3.done:
103     liveins: %vgpr0, %sgpr0_sgpr1_sgpr2_sgpr3:0x00000003
105     %sgpr3 = S_MOV_B32 61440
106     %sgpr2 = S_MOV_B32 -1
107     BUFFER_STORE_DWORD_OFFSET killed %vgpr0, killed %sgpr0_sgpr1_sgpr2_sgpr3, 0, 0, 0, 0, 0, implicit %exec :: (store 4 into %ir.out)
108     S_ENDPGM
112 # CHECK-LABEL: name: vccz_corrupt_undef_vcc
113 # CHECK: S_WAITCNT
114 # CHECK-NEXT: S_CBRANCH_VCCZ %bb.2.else, implicit undef %vcc
116 name:            vccz_corrupt_undef_vcc
117 alignment:       0
118 exposesReturnsTwice: false
119 legalized:       false
120 regBankSelected: false
121 selected:        false
122 tracksRegLiveness: true
123 liveins:
124   - { reg: '%sgpr0_sgpr1' }
125 frameInfo:
126   isFrameAddressTaken: false
127   isReturnAddressTaken: false
128   hasStackMap:     false
129   hasPatchPoint:   false
130   stackSize:       0
131   offsetAdjustment: 0
132   maxAlignment:    0
133   adjustsStack:    false
134   hasCalls:        false
135   maxCallFrameSize: 0
136   hasOpaqueSPAdjustment: false
137   hasVAStart:      false
138   hasMustTailInVarArgFunc: false
139 body:             |
140   bb.0.entry:
141     liveins: %sgpr0_sgpr1
143     %sgpr0_sgpr1 = S_LOAD_DWORDX2_IMM killed %sgpr0_sgpr1, 11, 0 :: (non-temporal dereferenceable invariant load 8 from `i64 addrspace(2)* undef`)
144     %sgpr7 = S_MOV_B32 61440
145     %sgpr6 = S_MOV_B32 -1
146     S_CBRANCH_VCCZ %bb.1.else, implicit undef %vcc
148   bb.2.if:
149     liveins: %sgpr6, %sgpr7, %sgpr0_sgpr1_sgpr2_sgpr3:0x00000003
151     %vgpr0 = V_MOV_B32_e32 9, implicit %exec
152     BUFFER_STORE_DWORD_OFFSET killed %vgpr0, killed %sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, 0, implicit %exec :: (volatile store 4 into `i32 addrspace(1)* undef`)
153     %vgpr0 = V_MOV_B32_e32 0, implicit %exec
154     S_BRANCH %bb.3.done
156   bb.1.else:
157     liveins: %sgpr6, %sgpr7, %sgpr0_sgpr1_sgpr2_sgpr3:0x00000003
159     %vgpr0 = V_MOV_B32_e32 100, implicit %exec
160     BUFFER_STORE_DWORD_OFFSET killed %vgpr0, killed %sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, 0, implicit %exec :: (volatile store 4 into `i32 addrspace(1)* undef`)
161     %vgpr0 = V_MOV_B32_e32 1, implicit %exec
163   bb.3.done:
164     liveins: %vgpr0, %sgpr0_sgpr1_sgpr2_sgpr3:0x00000003
166     %sgpr3 = S_MOV_B32 61440
167     %sgpr2 = S_MOV_B32 -1
168     BUFFER_STORE_DWORD_OFFSET killed %vgpr0, killed %sgpr0_sgpr1_sgpr2_sgpr3, 0, 0, 0, 0, 0, implicit %exec :: (store 4 into %ir.out)
169     S_ENDPGM