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][ARM][combine] Improve opportunities to generate cmn instructions


On 07/25/2013 10:13 AM, Kyrylo Tkachov wrote:
Hi all,

Currently on arm we miss some opportunities to generate the cmn instruction
(cmn r1, r2  ~  r1 + r2 == 0)
For example, for code:
int foo (int x, int y)
{
   if (x + y == 0)
      return 25;
   else
     return 5;
}

we generate
          add     r0, r0, r1
          cmp     r0, #0
          movne   r0, #5
          moveq   r0, #25

This could be improved. During investigation I noticed that combine tries to
transform x + y == 0 into x == -y, in RTL form: (eq (x) (neg y)) which is not
the canonical form and therefore doesn't get matched by a pattern we have that
would have produced a cmn instruction. Adding a re-canonicalization step in
simplify_comparison fixes that and allows us to match the correct patterns.

A new splitter is also added to arm that will allow us to produce forms
appropriate for cmn when doing comparisons other than == in the case given
above.

Bootstrapped on arm-linux-gnueabihf and x86_64-linux-gnu. Regtested on
arm-none-eabi on qemu.

Ok for trunk?


2013-07-25  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
             Richard Earnshaw  <richard.earnshaw@arm.com>

	* combine.c (simplify_comparison): Re-canonicalize operands
	where appropriate.
The combine part is fine.  Please install.

jeff


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