Skip to content

Commit bcaac5f

Browse files
committed
changed trunc pattern in oneuse
1 parent feda4bd commit bcaac5f

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

llvm/lib/Target/AMDGPU/SIInstructions.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3124,12 +3124,12 @@ def IMMBitSelConst : SDNodeXForm<imm, [{
31243124

31253125
// Handle the VALU case.
31263126
def : GCNPat <
3127-
(i1 (xor (i1 (DivergentUnaryFrag<trunc> i32:$a)), -1)),
3127+
(i1 (xor (i1 (DivergentUnaryFrag_oneuse<trunc> i32:$a)), -1)),
31283128
(V_CMP_NE_U32_e64 (V_AND_B32_e64 (i32 1), i32:$a), (i32 1))
31293129
>;
31303130

31313131
def : GCNPat <
3132-
(i1 (xor (i1 (DivergentUnaryFrag<trunc> i64:$a)), -1)),
3132+
(i1 (xor (i1 (DivergentUnaryFrag_oneuse<trunc> i64:$a)), -1)),
31333133
(V_CMP_NE_U32_e64 (V_AND_B32_e64 (i32 1),
31343134
(i32 (EXTRACT_SUBREG $a, sub0))), (i32 1))
31353135
>;

llvm/lib/Target/AMDGPU/VOPInstructions.td

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,19 @@ class DivergentUnaryFrag<SDPatternOperator Op> : PatFrag <
12671267
let GISelPredicateCode = [{return true;}];
12681268
}
12691269

1270+
class DivergentUnaryFrag_oneuse<SDPatternOperator Op> : PatFrag <
1271+
(ops node:$src0),
1272+
(Op $src0),
1273+
[{ return N->isDivergent(); }]> {
1274+
// This check is unnecessary as it's captured by the result register
1275+
// bank constraint.
1276+
//
1277+
// FIXME: Should add a way for the emitter to recognize this is a
1278+
// trivially true predicate to eliminate the check.
1279+
let GISelPredicateCode = [{return true;}];
1280+
let HasOneUse = 1;
1281+
}
1282+
12701283
class VOPPatOrNull<SDPatternOperator Op, VOPProfile P> {
12711284
list<dag> ret = !if(!ne(P.NeedPatGen,PatGenMode.NoPattern), VOPPatGen<Op, P>.ret, []);
12721285
}

llvm/test/CodeGen/AMDGPU/codegen-prepare-addrspacecast-non-null.ll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,22 +207,22 @@ define void @recursive_phis(i1 %cond, ptr addrspace(5) %ptr) {
207207
; DAGISEL-ASM: ; %bb.0: ; %entry
208208
; DAGISEL-ASM-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
209209
; DAGISEL-ASM-NEXT: v_and_b32_e32 v0, 1, v0
210-
; DAGISEL-ASM-NEXT: v_cmp_eq_u32_e64 s[4:5], 1, v0
211-
; DAGISEL-ASM-NEXT: v_cmp_ne_u32_e32 vcc, 1, v0
210+
; DAGISEL-ASM-NEXT: v_cmp_eq_u32_e32 vcc, 1, v0
212211
; DAGISEL-ASM-NEXT: v_lshrrev_b32_e64 v0, 6, s32
213-
; DAGISEL-ASM-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
212+
; DAGISEL-ASM-NEXT: s_and_saveexec_b64 s[4:5], vcc
214213
; DAGISEL-ASM-NEXT: ; %bb.1: ; %then
215214
; DAGISEL-ASM-NEXT: v_and_b32_e32 v0, 0xffff, v1
216215
; DAGISEL-ASM-NEXT: ; %bb.2: ; %finallyendcf.split
217-
; DAGISEL-ASM-NEXT: s_or_b64 exec, exec, s[6:7]
216+
; DAGISEL-ASM-NEXT: s_or_b64 exec, exec, s[4:5]
217+
; DAGISEL-ASM-NEXT: s_xor_b64 s[6:7], vcc, -1
218218
; DAGISEL-ASM-NEXT: s_mov_b64 s[4:5], 0
219-
; DAGISEL-ASM-NEXT: s_mov_b64 s[6:7], src_private_base
219+
; DAGISEL-ASM-NEXT: s_mov_b64 s[8:9], src_private_base
220220
; DAGISEL-ASM-NEXT: v_mov_b32_e32 v2, 7
221221
; DAGISEL-ASM-NEXT: .LBB7_3: ; %finally
222222
; DAGISEL-ASM-NEXT: ; =>This Inner Loop Header: Depth=1
223-
; DAGISEL-ASM-NEXT: s_and_b64 s[8:9], exec, vcc
224-
; DAGISEL-ASM-NEXT: s_or_b64 s[4:5], s[8:9], s[4:5]
225-
; DAGISEL-ASM-NEXT: v_mov_b32_e32 v1, s7
223+
; DAGISEL-ASM-NEXT: s_and_b64 s[10:11], exec, s[6:7]
224+
; DAGISEL-ASM-NEXT: s_or_b64 s[4:5], s[10:11], s[4:5]
225+
; DAGISEL-ASM-NEXT: v_mov_b32_e32 v1, s9
226226
; DAGISEL-ASM-NEXT: flat_store_dword v[0:1], v2
227227
; DAGISEL-ASM-NEXT: s_waitcnt vmcnt(0)
228228
; DAGISEL-ASM-NEXT: s_andn2_b64 exec, exec, s[4:5]

0 commit comments

Comments
 (0)