Skip to content

Commit bdd82d5

Browse files
authored
[GlobalISel] Convert unary propagate_undef_any_op opcodes to use new match syntax. NFC. (#119475)
1 parent 54ca1c4 commit bdd82d5

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

llvm/include/llvm/Target/GlobalISel/Combine.td

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,22 @@ def unary_undef_to_zero: GICombineRule<
424424
[{ return Helper.matchOperandIsUndef(*${root}, 1); }]),
425425
(apply [{ Helper.replaceInstWithConstant(*${root}, 0); }])>;
426426

427+
def unary_undef_to_undef_frags : GICombinePatFrag<
428+
(outs root:$dst), (ins),
429+
!foreach(op,
430+
[G_TRUNC, G_BITCAST, G_ANYEXT, G_PTRTOINT, G_INTTOPTR, G_FPTOSI,
431+
G_FPTOUI],
432+
(pattern (op $dst, $x), (G_IMPLICIT_DEF $x)))>;
433+
def unary_undef_to_undef : GICombineRule<
434+
(defs root:$dst),
435+
(match (unary_undef_to_undef_frags $dst)),
436+
(apply [{ Helper.replaceInstWithUndef(*${dst}.getParent()); }])>;
437+
427438
// Instructions where if any source operand is undef, the instruction can be
428439
// replaced with undef.
429440
def propagate_undef_any_op: GICombineRule<
430441
(defs root:$root),
431-
(match (wip_match_opcode G_ADD, G_FPTOSI, G_FPTOUI, G_SUB, G_XOR, G_TRUNC, G_BITCAST, G_ANYEXT, G_PTRTOINT, G_INTTOPTR):$root,
442+
(match (wip_match_opcode G_ADD, G_SUB, G_XOR):$root,
432443
[{ return Helper.matchAnyExplicitUseIsUndef(*${root}); }]),
433444
(apply [{ Helper.replaceInstWithUndef(*${root}); }])>;
434445

@@ -1919,6 +1930,7 @@ def undef_combines : GICombineGroup<[undef_to_fp_zero, undef_to_int_zero,
19191930
binop_left_undef_to_zero,
19201931
binop_right_undef_to_undef,
19211932
unary_undef_to_zero,
1933+
unary_undef_to_undef,
19221934
propagate_undef_any_op,
19231935
propagate_undef_all_ops,
19241936
propagate_undef_shuffle_mask,

0 commit comments

Comments
 (0)