diff mbox series

Fix PR85567

Message ID alpine.LSU.2.20.1805020955170.24704@zhemvz.fhfr.qr
State New
Headers show
Series Fix PR85567 | expand

Commit Message

Richard Biener May 2, 2018, 7:56 a.m. UTC
The following fixes into-SSA gimplification for SAVE_EXPRs introduced
late during GIMPLE.  In that case we can reasonably expect to have
a situation which gimplifies into sth without control flow so allow
SSA temps for its destination.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk
sofar.

Richard.

2018-05-02  Richard Biener  <rguenther@suse.de>

	PR middle-end/85567
	* gimplify.c (gimplify_save_expr): When in SSA form allow
	SAVE_EXPRs to compute to SSA vars.

	* gcc.dg/torture/pr85567.c: New testcase.
diff mbox series

Patch

Index: gcc/gimplify.c
===================================================================
--- gcc/gimplify.c	(revision 259755)
+++ gcc/gimplify.c	(working copy)
@@ -5927,8 +5927,11 @@  gimplify_save_expr (tree *expr_p, gimple
 	}
       else
 	/* The temporary may not be an SSA name as later abnormal and EH
-	   control flow may invalidate use/def domination.  */
-	val = get_initialized_tmp_var (val, pre_p, post_p, false);
+	   control flow may invalidate use/def domination.  When in SSA
+	   form then assume there are no such issues and SAVE_EXPRs only
+	   appear via GENERIC foldings.  */
+	val = get_initialized_tmp_var (val, pre_p, post_p,
+				       gimple_in_ssa_p (cfun));
 
       TREE_OPERAND (*expr_p, 0) = val;
       SAVE_EXPR_RESOLVED_P (*expr_p) = 1;
Index: gcc/testsuite/gcc.dg/torture/pr85567.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr85567.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr85567.c	(working copy)
@@ -0,0 +1,16 @@ 
+/* { dg-do compile } */
+
+extern void sincos(double x, double *sinx, double *cosx);
+
+void apply(void (*f)(double, double *, double *),
+	   double x, double *sinx, double *cosx)
+{
+  f(x, sinx, cosx);
+  return;
+}
+
+void apply_sincos(double x, double *sinx, double *cosx)
+{
+  apply(sincos, x, sinx, cosx);
+  return;
+}