From ffa8a92137cd41829d477be4ef1c1c28849ffee1 Mon Sep 17 00:00:00 2001 From: Sudakshina Das Date: Fri, 2 Jun 2017 15:32:41 +0000 Subject: [PATCH] [PATCH][AArch64] Allow CMP+SHIFT when comparing with zero gcc/ * config/aarch64/aarch64.c (aarch64_select_cc_mode): Return CC_SWP for comparision with zero. gcc/testsuite/ * gcc.target/aarch64/cmp_shifted_reg_1.c: New. From-SVN: r248836 --- gcc/ChangeLog | 5 +++++ gcc/config/aarch64/aarch64.c | 2 +- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.target/aarch64/cmp_shifted_reg_1.c | 11 +++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/aarch64/cmp_shifted_reg_1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 079f1fd61f0..070bb8f6db5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-06-02 Sudakshina Das + + * config/aarch64/aarch64.c (aarch64_select_cc_mode): Return CC_SWP for + comparision with zero. + 2017-06-02 Will Schmidt * config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Add handling for early expansion of vec_min and vec_max builtins. diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 7064f050a10..5707e5317e2 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -4767,7 +4767,7 @@ aarch64_select_cc_mode (RTX_CODE code, rtx x, rtx y) the comparison will have to be swapped when we emit the assembly code. */ if ((GET_MODE (x) == SImode || GET_MODE (x) == DImode) - && (REG_P (y) || GET_CODE (y) == SUBREG) + && (REG_P (y) || GET_CODE (y) == SUBREG || y == const0_rtx) && (GET_CODE (x) == ASHIFT || GET_CODE (x) == ASHIFTRT || GET_CODE (x) == LSHIFTRT || GET_CODE (x) == ZERO_EXTEND || GET_CODE (x) == SIGN_EXTEND)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 70a8335d5df..2f38470c9d1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-06-02 Sudakshina Das + + * gcc.target/aarch64/cmp_shifted_reg_1.c: New. + 2017-06-02 Will Schmidt * gcc.target/powerpc/fold-vec-minmax-char.c: New. diff --git a/gcc/testsuite/gcc.target/aarch64/cmp_shifted_reg_1.c b/gcc/testsuite/gcc.target/aarch64/cmp_shifted_reg_1.c new file mode 100644 index 00000000000..cacecf4e71d --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/cmp_shifted_reg_1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 " } */ + +int f3 (int x, int y) +{ + int res = x << 3; + return res != 0; +} + +/* We should combine the shift and compare */ +/* { dg-final { scan-assembler "cmp\.*\twzr, w\[0-9\]+, lsl 3" } } */ -- 2.30.2