re PR tree-optimization/47140 (error: conversion of register to a different size)
authorJakub Jelinek <jakub@redhat.com>
Sun, 2 Jan 2011 17:09:08 +0000 (18:09 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sun, 2 Jan 2011 17:09:08 +0000 (18:09 +0100)
PR tree-optimization/47140
* tree-ssa-ccp.c (evaluate_stmt): For binary assignments, use
TREE_TYPE (lhs) instead of TREE_TYPE (rhs1) as second argument
to bit_value_binop.

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

From-SVN: r168402

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr47140.c [new file with mode: 0644]
gcc/tree-ssa-ccp.c

index 343e510..9b74e07 100644 (file)
@@ -1,5 +1,10 @@
 2011-01-02  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/47140
+       * tree-ssa-ccp.c (evaluate_stmt): For binary assignments, use
+       TREE_TYPE (lhs) instead of TREE_TYPE (rhs1) as second argument
+       to bit_value_binop.
+
        PR rtl-optimization/47028
        * cfgexpand.c (gimple_expand_cfg): Insert entry edge
        insertions after parm_birth_insn instead of at the beginning
index 09e47cf..defb494 100644 (file)
@@ -1,5 +1,8 @@
 2011-01-02  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/47140
+       * gcc.c-torture/compile/pr47140.c: New test.
+
        PR rtl-optimization/47028
        * gcc.dg/pr47028.c: New test.
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr47140.c b/gcc/testsuite/gcc.c-torture/compile/pr47140.c
new file mode 100644 (file)
index 0000000..2adf53c
--- /dev/null
@@ -0,0 +1,25 @@
+/* PR tree-optimization/47140 */
+
+static inline int
+foo (int x, short y)
+{
+  return y == 0 ? x : x + y;
+}
+
+static inline unsigned short
+bar (unsigned short x, unsigned char y)
+{
+  return x - y;
+}
+
+int w;
+
+int baz (void);
+
+int
+test (void)
+{
+  int i;
+  for (i = 0; i < 50; i++)
+    w += foo ((unsigned char) (1 + baz ()) >= bar (0, 1), 0);
+}
index aea7edf..371620e 100644 (file)
@@ -2156,9 +2156,10 @@ evaluate_stmt (gimple stmt)
              if (INTEGRAL_TYPE_P (TREE_TYPE (rhs1))
                  || POINTER_TYPE_P (TREE_TYPE (rhs1)))
                {
+                 tree lhs = gimple_assign_lhs (stmt);
                  tree rhs2 = gimple_assign_rhs2 (stmt);
                  val = bit_value_binop (subcode,
-                                        TREE_TYPE (rhs1), rhs1, rhs2);
+                                        TREE_TYPE (lhs), rhs1, rhs2);
                }
              break;