re PR target/36362 (ICE in simplify_subreg)
authorJakub Jelinek <jakub@redhat.com>
Fri, 6 Jun 2008 13:23:04 +0000 (15:23 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 6 Jun 2008 13:23:04 +0000 (15:23 +0200)
PR target/36362
* gimplify.c (gimplify_expr) <case TRUTH_NOT_EXPR>: If *expr_p type
is not bool, boolify the whole *expr_p and convert to the desired type.

* gcc.c-torture/execute/20080529-1.c: New test.

From-SVN: r136434

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20080529-1.c [new file with mode: 0644]

index ce1eae639916ae579f3e8b771b966e4194dc1679..c7da7ddecdde937fb5cb1567c1dd04f09f9778d6 100644 (file)
@@ -1,3 +1,9 @@
+2008-06-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/36362
+       * gimplify.c (gimplify_expr) <case TRUTH_NOT_EXPR>: If *expr_p type
+       is not bool, boolify the whole *expr_p and convert to the desired type.
+
 2008-06-06  Jakub Jelinek  <jakub@redhat.com>
 
        * c-cppbuiltin.c (c_cpp_builtins): Change _OPENMP value to
index 0c2e5e244057127fc0f00810dbf57cde16e7db95..47a2fe7b43dfe6a94e0c3fb4d56e3d893a1af4a8 100644 (file)
@@ -5890,8 +5890,14 @@ gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p,
          break;
 
        case TRUTH_NOT_EXPR:
-         TREE_OPERAND (*expr_p, 0)
-           = gimple_boolify (TREE_OPERAND (*expr_p, 0));
+         if (TREE_CODE (TREE_TYPE (*expr_p)) != BOOLEAN_TYPE)
+           {
+             tree type = TREE_TYPE (*expr_p);
+             *expr_p = fold_convert (type, gimple_boolify (*expr_p));
+             ret = GS_OK;
+             break;
+           }
+
          ret = gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p, post_p,
                               is_gimple_val, fb_rvalue);
          recalculate_side_effects (*expr_p);
index 73e4a5e6c2ac4ad16f7e9d3b55dc39da64701d32..a1ce73c2761340fa3b2000dc4ffb5eaf66f53653 100644 (file)
@@ -1,3 +1,8 @@
+2008-06-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/36362
+       * gcc.c-torture/execute/20080529-1.c: New test.
+
 2008-06-06  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.dg/gomp/collapse-1.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20080529-1.c b/gcc/testsuite/gcc.c-torture/execute/20080529-1.c
new file mode 100644 (file)
index 0000000..cd42980
--- /dev/null
@@ -0,0 +1,17 @@
+/* PR target/36362 */
+
+extern void abort (void);
+
+int
+test (float c)
+{
+  return !!c * 7LL == 0;
+}
+
+int
+main (void)
+{
+  if (test (1.0f) != 0)
+    abort ();
+  return 0;
+}