2007-04-22 Andrew Pinski <andrew_pinski@playstation.sony.com>
authorpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Apr 2007 01:53:56 +0000 (01:53 +0000)
committerpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Apr 2007 01:53:56 +0000 (01:53 +0000)
        PR middle-end/31448
        * expr.c (reduce_to_bit_field_precision): Handle
        CONST_INT rtx's.

2007-04-22  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR middle-end/31448
        * gcc.c-torture/execute/pr31448.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@124054 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr31448.c [new file with mode: 0644]

index b9e35dc..a99d0c8 100644 (file)
@@ -1,3 +1,9 @@
+2007-04-22  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR middle-end/31448
+       * expr.c (reduce_to_bit_field_precision): Handle
+       CONST_INT rtx's.
+
 2007-04-22  Uros Bizjak  <ubizjak@gmail.com>
 
        PR tree-optimization/24659
index c644933..e239f4c 100644 (file)
@@ -8962,7 +8962,14 @@ reduce_to_bit_field_precision (rtx exp, rtx target, tree type)
   HOST_WIDE_INT prec = TYPE_PRECISION (type);
   if (target && GET_MODE (target) != GET_MODE (exp))
     target = 0;
-  if (TYPE_UNSIGNED (type))
+  /* For constant values, reduce using build_int_cst_type. */
+  if (GET_CODE (exp) == CONST_INT)
+    {
+      HOST_WIDE_INT value = INTVAL (exp);
+      tree t = build_int_cst_type (type, value);
+      return expand_expr (t, target, VOIDmode, EXPAND_NORMAL);
+    }
+  else if (TYPE_UNSIGNED (type))
     {
       rtx mask;
       if (prec < HOST_BITS_PER_WIDE_INT)
index 571c5d9..2546590 100644 (file)
@@ -1,3 +1,8 @@
+2007-04-22  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR middle-end/31448
+       * gcc.c-torture/execute/pr31448.c: New testcase.
+
 2007-04-22  Nick Clifton  <nickc@redhat.com>
 
        * gcc.dg/20020312-2.c: Add support for the FRV.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr31448.c b/gcc/testsuite/gcc.c-torture/execute/pr31448.c
new file mode 100644 (file)
index 0000000..720ba92
--- /dev/null
@@ -0,0 +1,36 @@
+/* PR middle-end/31448, this used to ICE during expand because
+   reduce_to_bit_field_precision was not ready to handle constants. */
+
+typedef struct _st {
+    int iIndex : 24;
+    int iIndex1 : 24;
+} st;
+st *next;
+void g(void)
+{
+    st *next = 0;
+    int nIndx;
+    const static int constreg[] = { 0,};
+    nIndx = 0;
+    next->iIndex = constreg[nIndx];
+}
+void f(void)
+{
+    int nIndx;
+    const static int constreg[] = { 0xFEFEFEFE,};
+    nIndx = 0;
+    next->iIndex = constreg[nIndx];
+    next->iIndex1 = constreg[nIndx];
+}
+int main(void)
+{
+  st a;
+  next = &a;
+  f();
+  if (next->iIndex != 0xFFFEFEFE)
+    __builtin_abort ();
+  if (next->iIndex1 != 0xFFFEFEFE)
+    __builtin_abort ();
+  return 0;
+}
+