This is the mail archive of the
mailing list for the GCC project.
Re: jump optimizations
- From: law at redhat dot com
- To: Danish Samad <danishsamad at yahoo dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 07 Mar 2002 09:40:56 -0700
- Subject: Re: jump optimizations
- Reply-to: law at redhat dot com
In message <firstname.lastname@example.org>, Danish Samad wr
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> how do you tell gcc, through the machine dexcription,
> to do jump optimization as shown in the sample code
> c code: assembly code
> if (i > j) cmp r3, r2 [length = 4]
> ble .L3
> In the c code above it checks if i>j but when
> converting to assembly it checks if it is <= and
> branches to the label corresponding to else
This is usually an indicator that the RTL you generate is exposing too
much of the target machine too early to the compiler. The compiler has
generic code which should be able to determine that the conditional is
Take your fragment and turn it into a usable C function such as:
if (i > j)
Compile it with -O2 -dap.
The first CSE pass should determine that the jump is a compile-time constant
and remove it. It should also determine that the value of "k" is a compile
time constant and eliminate the subtraction completely.
If this is not happening, it is likely because you've exposed too many
target details too early which in turn can confuse the optimizers.