]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: [multiple changes]
authorRichard Guenther <rguenther@suse.de>
Fri, 19 Jun 2009 21:44:24 +0000 (21:44 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 19 Jun 2009 21:44:24 +0000 (21:44 +0000)
2009-06-19  Richard Guenther  <rguenther@suse.de>

Backport from mainline:
2009-02-03  Andrew Pinski  <andrew_pinski@playstation.sony.com>

PR C++/36607
* convert.c (convert_to_integer): Treat OFFSET_TYPE like INTEGER_TYPE.

* g++.dg/expr/cast10.C: New test.

2009-02-03  Jakub Jelinek  <jakub@redhat.com>

PR target/35318
* function.c (match_asm_constraints_1): Skip over
initial optional % in the constraint.

* gcc.c-torture/compile/pr35318.c: New test.

2009-05-20  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/40204
* fold-const.c (fold_binary) <case BIT_AND_EXPR>: Avoid infinite
recursion if build_int_cst_type returns the same INTEGER_CST as
arg1.

* gcc.c-torture/compile/pr40204.c: New test.

From-SVN: r148730

gcc/ChangeLog
gcc/convert.c
gcc/fold-const.c
gcc/function.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/expr/cast10.C [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/compile/pr35318.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/compile/pr40204.c [new file with mode: 0644]

index 4a23b66c46c573a68e6d678827b27cc206c667b0..ddda82545765ef8041cd15f318a2fca7d19be4f6 100644 (file)
@@ -1,3 +1,24 @@
+2009-06-19  Richard Guenther  <rguenther@suse.de>
+
+       Backport from mainline:
+       2009-02-03  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR C++/36607
+       * convert.c (convert_to_integer): Treat OFFSET_TYPE like INTEGER_TYPE.
+
+       2009-05-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/40204
+       * fold-const.c (fold_binary) <case BIT_AND_EXPR>: Avoid infinite
+       recursion if build_int_cst_type returns the same INTEGER_CST as
+       arg1.
+
+       2009-02-03  Jakub Jelinek  <jakub@redhat.com>
+       PR target/35318
+       * function.c (match_asm_constraints_1): Skip over
+       initial optional % in the constraint.
 2009-06-19  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline:
index a9a22c52c53d52677a80f5d24456606624fbd45f..d5de95c1b46c7dfeb5f68539b379b12524622115 100644 (file)
@@ -491,6 +491,7 @@ convert_to_integer (tree type, tree expr)
     case INTEGER_TYPE:
     case ENUMERAL_TYPE:
     case BOOLEAN_TYPE:
+    case OFFSET_TYPE:
       /* If this is a logical operation, which just returns 0 or 1, we can
         change the type of the expression.  */
 
index a9010ebafd43f6b73d97a937399b6e8b722f8d47..f3c6de44ffd48c32ef63b9548e80b9bee31cb0c6 100644 (file)
@@ -11224,6 +11224,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
              if (prec < HOST_BITS_PER_WIDE_INT
                  || newmask == ~(unsigned HOST_WIDE_INT) 0)
                {
+                 tree newmaskt;
+
                  if (shift_type != TREE_TYPE (arg0))
                    {
                      tem = fold_build2 (TREE_CODE (arg0), shift_type,
@@ -11234,9 +11236,9 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
                    }
                  else
                    tem = op0;
-                 return fold_build2 (BIT_AND_EXPR, type, tem,
-                                     build_int_cst_type (TREE_TYPE (op1),
-                                                         newmask));
+                 newmaskt = build_int_cst_type (TREE_TYPE (op1), newmask);
+                 if (!tree_int_cst_equal (newmaskt, arg1))
+                   return fold_build2 (BIT_AND_EXPR, type, tem, newmaskt);
                }
            }
        }
index e12ed0b2fbaf5dc5a4a56f1d1aab920d92068f89..d36919ce4fedf6f5464b78d2986c82f9bbe38953 100644 (file)
@@ -5712,6 +5712,9 @@ match_asm_constraints_1 (rtx insn, rtx *p_sets, int noutputs)
       char *end;
       int match, j;
 
+      if (*constraint == '%')
+       constraint++;
+
       match = strtoul (constraint, &end, 10);
       if (end == constraint)
        continue;
index 9680a75847acd003c19b160c554cb37b22a6a708..c7273969e6f1033dbe22e3d10bae30f756df5842 100644 (file)
@@ -1,3 +1,21 @@
+2009-06-19  Richard Guenther  <rguenther@suse.de>
+
+       Backport from mainline:
+       2009-02-03  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR C++/36607
+       * g++.dg/expr/cast10.C: New test.
+
+       2009-05-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/40204
+       * gcc.c-torture/compile/pr40204.c: New test.
+
+       2009-02-03  Jakub Jelinek  <jakub@redhat.com>
+       PR target/35318
+       * gcc.c-torture/compile/pr35318.c: New test.
+
 2009-06-19  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline:
diff --git a/gcc/testsuite/g++.dg/expr/cast10.C b/gcc/testsuite/g++.dg/expr/cast10.C
new file mode 100644 (file)
index 0000000..cd3e0fc
--- /dev/null
@@ -0,0 +1,10 @@
+// { dg-do compile }
+// This used to error out because we would try to convert m to a short.
+
+
+struct a {};
+void b() {
+    int a::*m;
+    a *c;
+    short p = reinterpret_cast<char*>(&(c->*m)) - reinterpret_cast<char*>(c);
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr35318.c b/gcc/testsuite/gcc.c-torture/compile/pr35318.c
new file mode 100644 (file)
index 0000000..85bb362
--- /dev/null
@@ -0,0 +1,8 @@
+/* PR target/35318 */
+
+void
+foo ()
+{
+  double x = 4, y;
+  __asm__ volatile ("" : "=r,r" (x), "=r,r" (y) : "%0,0" (x), "m,r" (8));
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr40204.c b/gcc/testsuite/gcc.c-torture/compile/pr40204.c
new file mode 100644 (file)
index 0000000..3193284
--- /dev/null
@@ -0,0 +1,14 @@
+/* PR middle-end/40204 */
+
+struct S
+{
+  unsigned int a : 4;
+  unsigned int b : 28;
+} s;
+char c;
+
+void
+f (void)
+{
+  s.a = (c >> 4) & ~(1 << 4);
+}