diff mbox

xtensa: fix ICE on pr59037.c test

Message ID 1478027505-15674-1-git-send-email-jcmvbkbc@gmail.com
State New
Headers show

Commit Message

Max Filippov Nov. 1, 2016, 7:11 p.m. UTC
xtensa gcc gets ICE on pr59037.c test because its xtensa_output_literal
function cannot handle integer literals of sizes other than 4 and 8,
whereas the test uses 16-byte int vector.
Split integer literal formatting into the recursive function
xtensa_output_integer_literal_parts capable of handling literals of any
power of 2 size not less than 4.

2016-11-01  Max Filippov  <jcmvbkbc@gmail.com>
gcc/
	* config/xtensa/xtensa.c (xtensa_output_integer_literal_parts):
	New function.
	(xtensa_output_literal): Use xtensa_output_integer_literal_parts
	to format MODE_INT and MODE_PARTIAL_INT literals.
---
 gcc/config/xtensa/xtensa.c | 44 +++++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 21 deletions(-)

Comments

augustine.sterling@gmail.com Nov. 2, 2016, 5:23 p.m. UTC | #1
On Tue, Nov 1, 2016 at 12:11 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> xtensa gcc gets ICE on pr59037.c test because its xtensa_output_literal
> function cannot handle integer literals of sizes other than 4 and 8,
> whereas the test uses 16-byte int vector.
> Split integer literal formatting into the recursive function
> xtensa_output_integer_literal_parts capable of handling literals of any
> power of 2 size not less than 4.
>
> 2016-11-01  Max Filippov  <jcmvbkbc@gmail.com>
> gcc/
>         * config/xtensa/xtensa.c (xtensa_output_integer_literal_parts):
>         New function.
>         (xtensa_output_literal): Use xtensa_output_integer_literal_parts
>         to format MODE_INT and MODE_PARTIAL_INT literals.

Approved.
Max Filippov Nov. 2, 2016, 6:48 p.m. UTC | #2
On Wed, Nov 2, 2016 at 10:23 AM, augustine.sterling@gmail.com
<augustine.sterling@gmail.com> wrote:
> On Tue, Nov 1, 2016 at 12:11 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
>> xtensa gcc gets ICE on pr59037.c test because its xtensa_output_literal
>> function cannot handle integer literals of sizes other than 4 and 8,
>> whereas the test uses 16-byte int vector.
>> Split integer literal formatting into the recursive function
>> xtensa_output_integer_literal_parts capable of handling literals of any
>> power of 2 size not less than 4.
>>
>> 2016-11-01  Max Filippov  <jcmvbkbc@gmail.com>
>> gcc/
>>         * config/xtensa/xtensa.c (xtensa_output_integer_literal_parts):
>>         New function.
>>         (xtensa_output_literal): Use xtensa_output_integer_literal_parts
>>         to format MODE_INT and MODE_PARTIAL_INT literals.
>
> Approved.

Applied to trunk. Thank you!

-- Max
diff mbox

Patch

diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c
index 2115b57..6e8a25d 100644
--- a/gcc/config/xtensa/xtensa.c
+++ b/gcc/config/xtensa/xtensa.c
@@ -2535,13 +2535,32 @@  xtensa_output_addr_const_extra (FILE *fp, rtx x)
   return false;
 }
 
+static void
+xtensa_output_integer_literal_parts (FILE *file, rtx x, int size)
+{
+  if (size > 4 && !(size & (size - 1)))
+    {
+      rtx first, second;
+
+      split_double (x, &first, &second);
+      xtensa_output_integer_literal_parts (file, first, size / 2);
+      fputs (", ", file);
+      xtensa_output_integer_literal_parts (file, second, size / 2);
+    }
+  else if (size == 4)
+    {
+      output_addr_const (file, x);
+    }
+  else
+    {
+      gcc_unreachable();
+    }
+}
 
 void
 xtensa_output_literal (FILE *file, rtx x, machine_mode mode, int labelno)
 {
   long value_long[2];
-  int size;
-  rtx first, second;
 
   fprintf (file, "\t.literal .LC%u, ", (unsigned) labelno);
 
@@ -2580,25 +2599,8 @@  xtensa_output_literal (FILE *file, rtx x, machine_mode mode, int labelno)
 
     case MODE_INT:
     case MODE_PARTIAL_INT:
-      size = GET_MODE_SIZE (mode);
-      switch (size)
-	{
-	case 4:
-	  output_addr_const (file, x);
-	  fputs ("\n", file);
-	  break;
-
-	case 8:
-	  split_double (x, &first, &second);
-	  output_addr_const (file, first);
-	  fputs (", ", file);
-	  output_addr_const (file, second);
-	  fputs ("\n", file);
-	  break;
-
-	default:
-	  gcc_unreachable ();
-	}
+      xtensa_output_integer_literal_parts (file, x, GET_MODE_SIZE (mode));
+      fputs ("\n", file);
       break;
 
     default: