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: possible regression... where to look at?


On Sat, 13 Mar 2004, Richard Sandiford wrote:
> FWIW, I was looking at the same thing for MIPS earlier today.  The
> transformation seems to be coming from fold-const.c:fold_single_bit_test(),
> specifically the bit beginning:
>
>       /* Otherwise we have (A & C) != 0 where C is a single bit,
> 	 convert that into ((A >> C2) & 1).  Where C2 = log2(C).
> 	 Similarly for (A & C) == 0.  */
>
> This happens unconditionally, regardless of rtx_costs etc.  Obviously
> it's a win on some architectures if the result of the != or == is used as
> a strictly 0/1 value.  Unfortunately, it seems to get applied in other
> contexts too.

I previously worried about this myself, and even considered adding
a special case to BIT_AND_EXPR in do_jump.  However, I believe the
assumption is that if "(A & C1) op 0" isn't used in an assignment, the
later RTL simplification passes will transform "((A >> C2) & 1) != 0"
back into the unshifted sequence.  This certainly happens on x86.


The solutions include either (1) ensure that the inverse transformation
can always be performed on MIPS (and elsewhere) at the RTL-level, (2)
special case the inverse tranform in do_jump, (3) move this optimization
from fold into expand_expr and do_jump or (4) something else I haven't
though of.

Roger
--


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