]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/45059 (error: invalid operands in binary operation, leads...
authorJakub Jelinek <jakub@redhat.com>
Wed, 25 Aug 2010 09:36:35 +0000 (11:36 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 25 Aug 2010 09:36:35 +0000 (11:36 +0200)
PR tree-optimization/45059
* tree-ssa-reassoc.c (eliminate_redundant_comparison): Strip useless
type conversions from newop{1,2}.  Assert t is a comparison and
newop{1,2} after the stripping are gimple vals.

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

From-SVN: r163539

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

index 29c5aecd4b24ff2ab05d5aaa5649b1ab97a671d2..28a831a515bbc3ba3f6fdfe9a279f32570560ba6 100644 (file)
@@ -1,3 +1,10 @@
+2010-08-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/45059
+       * tree-ssa-reassoc.c (eliminate_redundant_comparison): Strip useless
+       type conversions from newop{1,2}.  Assert t is a comparison and
+       newop{1,2} after the stripping are gimple vals.
+
 2010-08-25  Tejas Belagod  <tejas.belagod@arm.com>
 
        * config/arm/iterators.md (VU, SE, V_widen_l): New.
index 7a92568cb70e68f60f9dfa7f2c835c6acdf99abd..db3ae97dfc1a0ba2b510fe863a86837f4d375061 100644 (file)
@@ -1,3 +1,8 @@
+2010-08-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/45059
+       * gcc.c-torture/compile/pr45059.c: New test.
+
 2010-08-25  Tejas Belagod  <tejas.belagod@arm.com>
 
        * lib/target-supports.exp (check_effective_target_vect_unpack):
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr45059.c b/gcc/testsuite/gcc.c-torture/compile/pr45059.c
new file mode 100644 (file)
index 0000000..3f13cdb
--- /dev/null
@@ -0,0 +1,23 @@
+/* PR tree-optimization/45059 */
+
+typedef unsigned int T;
+extern void foo (signed char *, int);
+
+static signed char a;
+static T b[1] = { -1 };
+static unsigned char c;
+
+static inline short int
+bar (short v)
+{
+  c |= a < b[0];
+  return 0;
+}
+
+int
+main ()
+{
+  signed char *e = &a;
+  foo (e, bar (bar (c)));
+  return 0;
+}
index fd0a6d803d5c7a8eaa09adc125e0580ffb27292d..f2264b603c4f21288800f06ba7ce268970bdb210 100644 (file)
@@ -1314,9 +1314,14 @@ eliminate_redundant_comparison (enum tree_code opcode,
          enum tree_code subcode;
          tree newop1;
          tree newop2;
+         gcc_assert (COMPARISON_CLASS_P (t));
          tmpvar = create_tmp_var (TREE_TYPE (t), NULL);
          add_referenced_var (tmpvar);
          extract_ops_from_tree (t, &subcode, &newop1, &newop2);
+         STRIP_USELESS_TYPE_CONVERSION (newop1);
+         STRIP_USELESS_TYPE_CONVERSION (newop2);
+         gcc_checking_assert (is_gimple_val (newop1)
+                              && is_gimple_val (newop2));
          sum = build_and_add_sum (tmpvar, newop1, newop2, subcode);
          curr->op = gimple_get_lhs (sum);
        }