On 4/1/20 9:28 AM, Richard Sandiford wrote:
> How important is it to describe the flags operation as a compare though?
> Could we instead use an unspec with three inputs, and keep it as :CC?
> That would still allow special-case matching for zero operands.
I'm not sure.
My guess is that the only interesting optimization for ADC/SBC is when
optimization determines that the low-part of op2 is zero, so that we can fold
[(set (reg cc) (compare ...))
(set (reg t0) (sub (reg a0) (reg b0))]
[(set (reg cc) (compare ...))
(set (reg t1) (sub (reg a1)
(sub (reg b1)
(geu (reg cc) (const 0)))))]
to
[(set (reg t0) (reg a0)]
[(set (reg cc) (compare ...))
(set (reg t1) (sub (reg a1) (reg b1))]
which combine should be able to do by propagating zeros across the compare+geu.
Though I suppose it's still possible to handle this with unspecs and
define_split, so that
[(set (reg cc)
(unspec [(reg a1) (reg b2) (geu ...)]
UNSPEC_SBCS)
(set (reg t1) ...)]
when the geu folds to (const_int 0), we can split this to a plain sub.
I'll see if I can make this work with a minimum of effort.
r~