public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-3481] gimplify: Call gimple_boolify on IFN_ASSUME argument [PR107368]
Date: Tue, 25 Oct 2022 08:45:12 +0000 (GMT)	[thread overview]
Message-ID: <20221025084512.F2B0538582AD@sourceware.org> (raw)

https://gcc.gnu.org/g:44e18da4d9c5faf189fe876986927be12ae4e4c4

commit r13-3481-g44e18da4d9c5faf189fe876986927be12ae4e4c4
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Oct 25 10:42:59 2022 +0200

    gimplify: Call gimple_boolify on IFN_ASSUME argument [PR107368]
    
    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.

Diff:
---
 gcc/gimplify.cc                      |  2 +-
 gcc/testsuite/gcc.dg/attr-assume-5.c | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 44cc9e6677b..d236ef948bc 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -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
index 00000000000..8aa0f361dad
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/attr-assume-5.c
@@ -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;
+}

                 reply	other threads:[~2022-10-25  8:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221025084512.F2B0538582AD@sourceware.org \
    --to=jakub@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).