On Mon, 11 May 2026 at 13:18, Richard Biener <[email protected]> wrote:
>
> > +  (if (INTEGRAL_TYPE_P (type)
> > +       && TYPE_UNSIGNED (type)
> > +       && integer_pow2p (@3))
> > +   (with {
> > +     tree shift = build_int_cst (integer_type_node, tree_log2 (@3));
> > +    }
> > +    (plus @2
> > +         (lshift
> > +           (convert (convert:boolean_type_node
> > +             (cmp @0 (plus @0 @1))))
>
> Do not replicate (cmp ...), instead capture it and re-use that captured
> value here.
>
> Otherwise looks reasonable.  It may raise eybrows from AVR folks,
> a wide shift might be expensive (but at least not as expensive as
> a multiplication).
>
> You are tackling 'type' wider than word_mode, right?

The intended target is any reasonable integer width:
  - word_mode: the natural case for the cover-letter target (longhand
64x64->128 on 64-bit hosts, where `type` = DImode = word_mode).
  - wider than word_mode: hand-rolled 64-bit chains compiled for
32-bit hosts (type = DImode > word_mode = SImode).
  - narrower than word_mode: hand-rolled 32-bit chains on 64-bit hosts
(type = SImode < word_mode = DImode). This is a real workload we want
to fire on.

The pattern as written does not restrict on precision and
intentionally accepts all three.

Thanks,
Philipp.

Reply via email to