public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, AARCH64] Fix  ICE in CCMP (PR64015)
@ 2014-11-24  8:21 Zhenqiang Chen
  2014-11-24  8:21 ` Andrew Pinski
  2014-11-24  9:49 ` Richard Henderson
  0 siblings, 2 replies; 16+ messages in thread
From: Zhenqiang Chen @ 2014-11-24  8:21 UTC (permalink / raw)
  To: gcc-patches; +Cc: Marcus Shawcroft

Hi,

Expand pass always uses sign-extend to represent constant value. For the
case in the patch, a 8-bit unsigned value "252" is represented as "-4",
which pass the ccmn check. After mode conversion, "-4" becomes "252", which
leads to mismatch.

The patch adds another operand check after mode conversion.

No make check regression with qemu.

OK for trunk?

Thanks!
-Zhenqiang

ChangeLog:
2014-11-24  Zhenqiang Chen  <zhenqiang.chen@arm.com>

	PR target/64015
	* config/aarch64/aarch64.c (aarch64_gen_ccmp_first): Recheck operand
	after mode conversion.
	(aarch64_gen_ccmp_next): Likewise.

testsuite/ChangeLog:
2014-11-24  Zhenqiang Chen  <zhenqiang.chen@arm.com>

	* gcc.target/aarch64/pr64015.c: New test.

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 1809513..203d095 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -10311,7 +10311,10 @@ aarch64_gen_ccmp_first (int code, rtx op0, rtx op1)
   if (!aarch64_plus_operand (op1, GET_MODE (op1)))
     op1 = force_reg (mode, op1);
 
-  if (!aarch64_convert_mode (&op0, &op1, unsignedp))
+  if (!aarch64_convert_mode (&op0, &op1, unsignedp)
+	 /* Some negative value might be transformed into a positive one.
+	    So need recheck here.  */
+      || !aarch64_plus_operand (op1, GET_MODE (op1)))
     return NULL_RTX;
 
   mode = aarch64_code_to_ccmode ((enum rtx_code) code);
@@ -10344,7 +10347,10 @@ aarch64_gen_ccmp_next (rtx prev, int cmp_code, rtx
op0, rtx op1, int bit_code)
       || !aarch64_ccmp_operand (op1, GET_MODE (op1)))
     return NULL_RTX;
 
-  if (!aarch64_convert_mode (&op0, &op1, unsignedp))
+  if (!aarch64_convert_mode (&op0, &op1, unsignedp)
+	 /* Some negative value might be transformed into a positive one.
+	    So need recheck here.  */
+      || !aarch64_ccmp_operand (op1, GET_MODE (op1)))
     return NULL_RTX;
 
   mode = aarch64_code_to_ccmode ((enum rtx_code) cmp_code);

diff --git a/gcc/testsuite/gcc.target/aarch64/pr64015.c
b/gcc/testsuite/gcc.target/aarch64/pr64015.c
new file mode 100644
index 0000000..eeed665
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr64015.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options " -O2 " } */
+int
+test (unsigned short a, unsigned char b)
+{
+  return a > 0xfff2 && b > 252;
+}



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-01-18 20:52 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-24  8:21 [PATCH, AARCH64] Fix ICE in CCMP (PR64015) Zhenqiang Chen
2014-11-24  8:21 ` Andrew Pinski
2014-11-24  9:49 ` Richard Henderson
2014-11-25  9:11   ` Zhenqiang Chen
2014-11-25  9:37     ` Richard Henderson
2014-11-26 10:00       ` Zhenqiang Chen
2014-11-28 17:28         ` Richard Henderson
2014-12-12  7:52       ` Zhenqiang Chen
2014-12-12 19:25         ` Richard Henderson
2014-12-15  9:05           ` Zhenqiang Chen
2015-01-15 15:40             ` Jiong Wang
2015-01-15 18:28             ` Richard Henderson
2015-01-16 11:01               ` Marcus Shawcroft
2015-01-18 21:26                 ` Christophe Lyon
2015-01-18 22:12                   ` Andrew Pinski
2015-01-18 23:29                     ` Christophe Lyon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).