@@ -424,11 +424,22 @@ def unary_undef_to_zero: GICombineRule<
424
424
[{ return Helper.matchOperandIsUndef(*${root}, 1); }]),
425
425
(apply [{ Helper.replaceInstWithConstant(*${root}, 0); }])>;
426
426
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
+
427
438
// Instructions where if any source operand is undef, the instruction can be
428
439
// replaced with undef.
429
440
def propagate_undef_any_op: GICombineRule<
430
441
(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,
432
443
[{ return Helper.matchAnyExplicitUseIsUndef(*${root}); }]),
433
444
(apply [{ Helper.replaceInstWithUndef(*${root}); }])>;
434
445
@@ -1919,6 +1930,7 @@ def undef_combines : GICombineGroup<[undef_to_fp_zero, undef_to_int_zero,
1919
1930
binop_left_undef_to_zero,
1920
1931
binop_right_undef_to_undef,
1921
1932
unary_undef_to_zero,
1933
+ unary_undef_to_undef,
1922
1934
propagate_undef_any_op,
1923
1935
propagate_undef_all_ops,
1924
1936
propagate_undef_shuffle_mask,
0 commit comments