This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: jump bypass confuses noce_try_minmax


On Fri, Nov 21, 2003 at 08:44:46PM -0500, DJ Delorie wrote:

> Consider this test case:
> 
> int foo(int a)
> {
>   if (a >= 7)
>     a = 7;
>   if (a < -8)
>     a = -8;
>   return a;
> }

I would not have coded it this way, because on most architectures
I would get worse code.

> On a target with smin/smax insns, it can be coded trivially:
> 
>   a = smin(a,7);
>   a = smax(a,-8);
>   return a;
> 
> However, the "jump bypass" optimization changes it to this:
> 
> int foo(int a)
> {
>   if (a >= 7)
>     a = 7;
>   else if (a < -8)
>     a = -8;
>   return a;
> }

and this is the way that most people would be more likely to code it.

> And now noce_try_minmax cannot match the min operation, and you end up
> with conditional branches and such.  Note that adding asm("") between
> the conditionals yields the expected output.
>
> Should jump bypassing be deferred until after ifcvt?

But if you do that, doesn't the code get worse on architectures that don't
have min and max instructions (by increasing the number of tests)?

It seems it would be better to figure out how smin/smax could be used
in the second case, since it would make the instructions match in more
cases.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]