public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] gimplify: Call gimple_boolify on IFN_ASSUME argument [PR107368]
@ 2022-10-25  8:48 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2022-10-25  8:48 UTC (permalink / raw)
  To: gcc-patches

Hi!

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.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.

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.jj	2022-10-24 10:22:08.590902730 +0200
+++ gcc/gimplify.cc	2022-10-24 11:01:54.121339779 +0200
@@ -3586,7 +3586,7 @@ gimplify_call_expr (tree *expr_p, gimple
 	     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;
--- gcc/testsuite/gcc.dg/attr-assume-5.c.jj	2022-10-24 11:13:47.169624469 +0200
+++ gcc/testsuite/gcc.dg/attr-assume-5.c	2022-10-24 11:16:11.137662896 +0200
@@ -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;
+}

	Jakub


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-25  8:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-25  8:48 [committed] gimplify: Call gimple_boolify on IFN_ASSUME argument [PR107368] Jakub Jelinek

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).