https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126957
Bug ID: 126957
Summary: The convert for mul_carry_low_sum/mul_carry_cross_sum
(mul_carry_low?) is not optional for gimple
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: internal-improvement
Severity: enhancement
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
These all do:
```
/* Carry from low-sum overflow: (cast?) (hilo > low_sum) << N.
No explicit type/width guard needed: mul_low_sum delegates to
mul_cross_sum + mul_hi + mul_lolo, which provide deep structural
constraints, and @0 ties the shift amount to the inner constants. */
(match (mul_carry_low_sum @op0 @op1 @mul_hilo0 @mul_hilo1 @mul_hilo2 @0 @1)
(lshift
(convert? (gt
@mul_hilo0
(mul_low_sum @op0 @op1 @mul_hilo1 @mul_hilo2 INTEGER_CST@0
INTEGER_CST@1)))
INTEGER_CST@0))
/* Carry from cross-sum overflow: (cast?) (hilo > cross_sum) << N.
Explicit guard required because mul_cross_sum is just (plus:c @0 @1)
with no inherent type or halfwidth constraint. */
(match (mul_carry_cross_sum @mul_hilo0 @mul_hilo1 @mul_hilo2 @0)
(lshift
(convert? (gt
@mul_hilo0
(mul_cross_sum @mul_hilo1 @mul_hilo2)))
INTEGER_CST@0)
(with { tree op_type = TREE_TYPE (@mul_hilo0); }
(if (INTEGRAL_TYPE_P (op_type)
&& TYPE_UNSIGNED (op_type)
&& TYPE_PRECISION (op_type) % 2 == 0
&& tree_fits_uhwi_p (@0)
&& tree_to_uhwi (@0) == TYPE_PRECISION (op_type) / 2))))
/* Carry from addition overflow: (cast?) (a > a + b).
:c on gt also matches the LT form: (cast?) (a + b < a). */
(match (mul_carry_low @0 @1)
(convert?
(gt:c @0 (plus:c @1 @0)))
(with { tree op_type = TREE_TYPE (@0); }
(if (INTEGRAL_TYPE_P (op_type) && TYPE_UNSIGNED (op_type)))))
```
But in gimple the convert is not optional from a comparison (boolean type; 1bit
type) to a different integer type. So the optional `?` should be removed.