]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gimplify: Call gimple_boolify on IFN_ASSUME argument [PR107368]
authorJakub Jelinek <jakub@redhat.com>
Tue, 25 Oct 2022 08:42:59 +0000 (10:42 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 25 Oct 2022 08:45:04 +0000 (10:45 +0200)
The following testcase ICEs in C, because assume attribute condition
has int type rather than bool and the gimplification into GIMPLE_ASSUME
assigns it into a bool variable.

Fixed by calling gimple_boolify.

2022-10-25  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/107368
* gimplify.cc (gimplify_call_expr): For complex IFN_ASSUME
conditions call gimple_boolify on the condition.

* gcc.dg/attr-assume-5.c: New test.

gcc/gimplify.cc
gcc/testsuite/gcc.dg/attr-assume-5.c [new file with mode: 0644]

index 44cc9e6677ba124321e79ee1205663a31bace626..d236ef948bcae15fda01c05163867a866ca6e016 100644 (file)
@@ -3584,7 +3584,7 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value)
             a separate function easily.  */
          tree guard = create_tmp_var (boolean_type_node);
          *expr_p = build2 (MODIFY_EXPR, void_type_node, guard,
-                           CALL_EXPR_ARG (*expr_p, 0));
+                           gimple_boolify (CALL_EXPR_ARG (*expr_p, 0)));
          *expr_p = build3 (BIND_EXPR, void_type_node, NULL, *expr_p, NULL);
          push_gimplify_context ();
          gimple_seq body = NULL;
diff --git a/gcc/testsuite/gcc.dg/attr-assume-5.c b/gcc/testsuite/gcc.dg/attr-assume-5.c
new file mode 100644 (file)
index 0000000..8aa0f36
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR tree-optimization/107368 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+double
+f4 (double x)
+{
+  [[gnu::assume (x && x > 0.0)]];
+  return x;
+}