https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127111
Bug ID: 127111
Summary: unsigned _BitInt(32) is not treated like unsigned int
for long mul
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: tree-optimization
Assignee: pinskia at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Created attachment 65437
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65437&action=edit
testcase
Take the following testcase. both mulh_carry_32 and mulh_carry_32_bi should be
detected as a high part of a widening multiply . But only the non _BitInt one
is.
This is because of:
&& TREE_CODE (lhs_type) != BITINT_TYPE
Which is part of long_mul_classify_match.
And also this:
```
/* Long-multiply high-part emit chain produced by forwprop's recognizer:
(N) ((2N) op1 * (2N) op2) >> N
`(convert? @X)` accepts a bare operand (PRE may hoist the (T_2N) cast
out into a PHI on a shared slot). The lowering splits an operand
wider than T_N into T_N halves rather than truncating it. Wide type
must be unsigned mode-precision integer of even width; BITINT_TYPE is
refused. */
(match (long_mul_high_chain @0 @1)
(convert (rshift (mult:c@3 (convert? @0) (convert? @1)) INTEGER_CST@2))
(with { tree wide_type = TREE_TYPE (@3); }
(if (INTEGRAL_TYPE_P (wide_type)
&& TYPE_UNSIGNED (wide_type)
&& type_has_mode_precision_p (wide_type)
&& TREE_CODE (wide_type) != BITINT_TYPE
&& TYPE_PRECISION (wide_type) >= 8
&& TYPE_PRECISION (wide_type) % 4 == 0
&& wi::to_wide (@2) == TYPE_PRECISION (wide_type) / 2))))
```