Skip to content

[GlobalISel] Convert unary propagate_undef_any_op opcodes to use new match syntax. NFC. #119475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion llvm/include/llvm/Target/GlobalISel/Combine.td
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,22 @@ def unary_undef_to_zero: GICombineRule<
[{ return Helper.matchOperandIsUndef(*${root}, 1); }]),
(apply [{ Helper.replaceInstWithConstant(*${root}, 0); }])>;

def unary_undef_to_undef_frags : GICombinePatFrag<
(outs root:$dst), (ins),
!foreach(op,
[G_TRUNC, G_BITCAST, G_ANYEXT, G_PTRTOINT, G_INTTOPTR, G_FPTOSI,
G_FPTOUI],
(pattern (op $dst, $x), (G_IMPLICIT_DEF $x)))>;
def unary_undef_to_undef : GICombineRule<
(defs root:$dst),
(match (unary_undef_to_undef_frags $dst)),
(apply [{ Helper.replaceInstWithUndef(*${dst}.getParent()); }])>;

// Instructions where if any source operand is undef, the instruction can be
// replaced with undef.
def propagate_undef_any_op: GICombineRule<
(defs root:$root),
(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,
(match (wip_match_opcode G_ADD, G_SUB, G_XOR):$root,
[{ return Helper.matchAnyExplicitUseIsUndef(*${root}); }]),
(apply [{ Helper.replaceInstWithUndef(*${root}); }])>;

Expand Down Expand Up @@ -1919,6 +1930,7 @@ def undef_combines : GICombineGroup<[undef_to_fp_zero, undef_to_int_zero,
binop_left_undef_to_zero,
binop_right_undef_to_undef,
unary_undef_to_zero,
unary_undef_to_undef,
propagate_undef_any_op,
propagate_undef_all_ops,
propagate_undef_shuffle_mask,
Expand Down
Loading