This is the mail archive of the gcc-patches@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: ARM patch: New cbranchqi, cbranchhi patterns for Thumb-1


On Thu, 2010-07-15 at 15:24 +0200, Bernd Schmidt wrote:
> On Thumb-1, comparisons of integer values smaller than a word can be
> done by shifting the value to the left.  This patch adds a new macroized
> pattern, cbranch<mode>4_insn, which is used for QImode and HImode, and
> does exactly that.  Effects:
> 
> -       lsl     r2, r1, #24
> -       lsr     r2, r2, #24
> -       cmp     r2, #0
> +       lsl     r1, #24
>         bne     .L195
> 
> This uses the neat trick of putting a matching constraint on a
> match_scratch.
> 
> An earlier version (with slightly more stupid code) was regression
> tested on qemu/arm-linux with my usual set of three flags.  This version
> generates identical code as the tested one for all my testcases.  Ok if
> retest passes?
> 
> 
> Bernd

This is going to only set the N and Z flags correctly.  V and C will
have different values.   Having looked at arm_select_cc_mode I can't
quite convince myself that it will be safe for inequality comparisons.
The only relevent test in that that I can see is

  if (GET_MODE (x) == QImode && (op == EQ || op == NE))
    return CC_Zmode;

Which handles your example, but none of the others.

Also note, the same trick should be usable on ARM and Thumb2 if we don't
do that already.

R.



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