aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>2013-09-09 13:32:50 +0000
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>2013-09-09 13:32:50 +0000
commit274b2532360e1615cdbde890c32c928c69ac45cc (patch)
treebad4ff0c666dd569aee31c3a25352152de9952f1 /gcc
parent467a3558efb2d9ac55f643ad41d82c70477ea1de (diff)
downloadgcc-274b2532360e1615cdbde890c32c928c69ac45cc.zip
gcc-274b2532360e1615cdbde890c32c928c69ac45cc.tar.gz
gcc-274b2532360e1615cdbde890c32c928c69ac45cc.tar.bz2
aarch64.c (aarch64_select_cc_mode): Return CC_SWP for comparison with negated operand.
[gcc/] 2013-09-09 Kyrylo Tkachov <kyrylo.tkachov@arm.com> * config/aarch64/aarch64.c (aarch64_select_cc_mode): Return CC_SWP for comparison with negated operand. * config/aarch64/aarch64.md (compare_neg<mode>): Match canonical RTL form. [gcc/testsuite/] 2013-09-09 Kyrylo Tkachov <kyrylo.tkachov@arm.com> * gcc.target/aarch64/cmn-neg.c: New test. From-SVN: r202400
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/config/aarch64/aarch64.c5
-rw-r--r--gcc/config/aarch64/aarch64.md10
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.target/aarch64/cmn-neg.c33
5 files changed, 51 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 228fd1ba..9a94ff4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2013-09-09 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
+
+ * config/aarch64/aarch64.c (aarch64_select_cc_mode): Return CC_SWP for
+ comparison with negated operand.
+ * config/aarch64/aarch64.md (compare_neg<mode>): Match canonical RTL form.
+
2013-09-09 Richard Biener <rguenther@suse.de>
PR middle-end/58326
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 7635e1e..d0bd38e 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -3313,14 +3313,15 @@ aarch64_select_cc_mode (RTX_CODE code, rtx x, rtx y)
|| GET_CODE (x) == NEG))
return CC_NZmode;
- /* A compare with a shifted operand. Because of canonicalization,
+ /* A compare with a shifted or negated operand. Because of canonicalization,
the comparison will have to be swapped when we emit the assembly
code. */
if ((GET_MODE (x) == SImode || GET_MODE (x) == DImode)
&& (GET_CODE (y) == REG || GET_CODE (y) == SUBREG)
&& (GET_CODE (x) == ASHIFT || GET_CODE (x) == ASHIFTRT
|| GET_CODE (x) == LSHIFTRT
- || GET_CODE (x) == ZERO_EXTEND || GET_CODE (x) == SIGN_EXTEND))
+ || GET_CODE (x) == ZERO_EXTEND || GET_CODE (x) == SIGN_EXTEND
+ || GET_CODE (x) == NEG))
return CC_SWPmode;
/* A compare of a mode narrower than SI mode against zero can be done
diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index f37f98f..0cd7da7 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -1480,12 +1480,12 @@
)
(define_insn "*compare_neg<mode>"
- [(set (reg:CC CC_REGNUM)
- (compare:CC
- (match_operand:GPI 0 "register_operand" "r")
- (neg:GPI (match_operand:GPI 1 "register_operand" "r"))))]
+ [(set (reg:CC_SWP CC_REGNUM)
+ (compare:CC_SWP
+ (neg:GPI (match_operand:GPI 0 "register_operand" "r"))
+ (match_operand:GPI 1 "register_operand" "r")))]
""
- "cmn\\t%<w>0, %<w>1"
+ "cmn\\t%<w>1, %<w>0"
[(set_attr "v8type" "alus")
(set_attr "type" "alus_reg")
(set_attr "mode" "<MODE>")]
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3bb49d9..ffe4acb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2013-09-09 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
+
+ * gcc.target/aarch64/cmn-neg.c: New test.
+
2013-09-09 Richard Biener <rguenther@suse.de>
PR middle-end/58326
diff --git a/gcc/testsuite/gcc.target/aarch64/cmn-neg.c b/gcc/testsuite/gcc.target/aarch64/cmn-neg.c
new file mode 100644
index 0000000..05c8bbf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/cmn-neg.c
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+/* { dg-options "-O2 --save-temps" } */
+
+extern void abort (void);
+
+void __attribute__ ((noinline))
+foo_s32 (int a, int b)
+{
+ if (a < -b)
+ abort ();
+}
+/* { dg-final { scan-assembler "cmn\tw\[0-9\]" } } */
+
+void __attribute__ ((noinline))
+foo_s64 (long long a, long long b)
+{
+ if (a < -b)
+ abort ();
+}
+/* { dg-final { scan-assembler "cmn\tx\[0-9\]" } } */
+
+
+int
+main (void)
+{
+ int a = 30;
+ int b = 42;
+ foo_s32 (a, b);
+ foo_s64 (a, b);
+ return 0;
+}
+
+/* { dg-final { cleanup-saved-temps } } */