On Mon, 23 Feb 2026, Avinash Jayakar wrote:

> 
> 
> On Mon, 2026-02-23 at 11:21 +0100, Richard Biener wrote:
> > On Mon, Feb 23, 2026 at 10:53 AM Avinash Jayakar
> > <[email protected]> wrote:
> > > 
> > 
> > I wonder whether match.pd matches with (cond^ ...) similar to
> > the saturating arithmetic patterns can be used to make the matchings
> > more maintainable?
> > 
> Initially I tried to write simplify pattern in match.pd, that would
> recognize a >= b ? (a > b) : -1 to a == b? 0 : (a < b) -1: 1. Which
> enabled optimize_spaceship method. It did work when source was written
> with ternary operator.
> But one problem was that if source is written with if-else instead of
> ternary, it did not work.
> if (a >= b) return (a > b) else return -1;

I was suggesting a

(match (spaceship_lt_gt @0 @1 ...)
 (...))

and to call that from the optimize_spaceship function.

Richard.

Reply via email to