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: [PATCH: PR target/44072] Replace "cmp r0, -1" by "adds r0, 1" in thumb2


On Wed, 2010-05-12 at 16:43 +0800, Carrot Wei wrote:
> Hi
> 
> Both "cmp r0, -1" and "adds r0, 1" have the same effect when used to set
> conditions for following branch. But adds with small positive immediate is a
> 16 bit instruction and cmp with negative immediate is a 32 bit instruction. So
> we prefer adds in thumb2.
> 
> Thumb1 already has an insn pattern "cbranchsi4_scratch" to do this, this patch
> adds the corresponding insn pattern for thumb2.
> 
> +
> +(define_insn "thumb2_cbranchsi4_scratch"
> +  [(set (pc) (if_then_else
> +             (match_operator 4 "arm_comparison_operator"
> +              [(match_operand:SI 1 "s_register_operand" "l,?h,0")
> +               (match_operand:SI 2 "thumb1_cmpneg_operand" "Pt,Ps,Ps")])

You should put the constrains in the order that they are preferred,
rather than trying to force the behaviour with '?'.  So the constraints
for op1 should be "l,0,h" and the rest of the pattern adjusted to match.

OK with that change.

R.


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