This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR85567
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 2 May 2018 09:56:51 +0200 (CEST)
- Subject: [PATCH] Fix PR85567
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.
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;
+}