On 03/01/13 22:39, Andrew Pinski wrote:
Hi,
   For aarch64, we don't CSE some cmp away.  This patch fixes the case
where we are CSE across some basic-blocks like:
int f(int a, int b)
{
   if(a<b)
     return 1;
   if(a>b)
     return -1;
   return 0;
}
--- CUT ---
To fix this, I implemented the target hook
TARGET_FIXED_CONDITION_CODE_REGS as there was already code in CSE
which uses this target hook to find the extra setting of the CC
registers.

OK?  Build and tested on aarch64-thunder-elf (using Cavium's internal
simulator).  Build a cross to aarch64-thunder-linux-gnu and a Canadian
cross with that one for the native toolchain.

Thanks,
Andrew Pinski

        * config/aarch64/aarch64.c (aarch64_fixed_condition_code_regs):
        New function.
        (TARGET_FIXED_CONDITION_CODE_REGS): Define.

        * gcc.target/aarch64/cmp-1.c: New testcase.


fixed_condition_code.diff.txt


        * config/aarch64/aarch64.c (aarch64_fixed_condition_code_regs):
        New function.
        (TARGET_FIXED_CONDITION_CODE_REGS): Define.

        * gcc.target/aarch64/cmp-1.c: New testcase.

Index: config/aarch64/aarch64.c
===================================================================
--- config/aarch64/aarch64.c    (revision 194872)
+++ config/aarch64/aarch64.c    (working copy)
@@ -3041,6 +3041,16 @@ aarch64_const_double_zero_rtx_p (rtx x)
    return REAL_VALUES_EQUAL (r, dconst0);
  }

+/* Return the fixed registers used for condition codes.  */
+
+static bool
+aarch64_fixed_condition_code_regs (unsigned int *p1, unsigned int *p2)
+{
+  *p1 = CC_REGNUM;
+  *p2 = -1;

Please use INVALID_REGNUM here (as the documentation states).

Otherwise, OK.

A backport to the AArch64-4.7 branch would be appreciated.

R.

Reply via email to