> optabs.c's expand_abs_nojump already knows this trick: > > /* If this machine has expensive jumps, we can do integer absolute > value of X as (((signed) x >> (W-1)) ^ x) - ((signed) x >> (W-1)), > where W is the width of MODE. */ > > So if you define BRANCH_COST to be 2 or more there should be no need for > this pattern at all. Yes, I just confirmed this. With no abssi2 pattern, this: int side; int foo(int x) { side = x >> 31; return abs(x); }
does indeed produce: foo: ashr.l $r1,$r0,31 sta.l side,$r1 xor.l $r0,$r1,$r0 sub.l $r0,$r0,$r1 return Thanks. -- James Bowman FTDI Open Source Liaison