This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Do not emit SAVE_EXPR for already assigned SSA_NAMEs (PR71606).


On 07/01/2016 12:15 PM, Richard Biener wrote:
> IMHO using fold-convert in this case is bogus and ideally the testcase
> should have been diagnosed.
> 
> fold_convertible_p has a comment
> 
> /* Returns true, if ARG is convertible to TYPE using a NOP_EXPR.  *
> 
> but clearly it isn't generating just a NOP_EXPR (or VIEW_CONVERT_EXPR
> or other single operation) here.
> 
> So that is the thing to fix.  The way we build / insert the init stmts
> can also be improved by properly
> gimplifying the rhs first but of course that likely runs into the
> SAVE_EXPR case you mentioned.
> 
> Richard.

Hello Richard.

I've tried to mark COMPLEX_TYPE as not acceptable by fold_convertible_p,
which fixes the ICE and regression and bootstrap on x86_64-linux-gnu also looks
fine.

Is it sufficient, or we would need more sophisticated approach to handle the PR?

Thanks,
Martin
>From 9c11a34d262bccd2185f2cdcaa3b9db420366073 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Wed, 22 Jun 2016 18:07:55 +0200
Subject: [PATCH] Do not consider COMPLEX_TYPE as fold_convertible_p

gcc/ChangeLog:

2016-06-22  Martin Liska  <mliska@suse.cz>

	PR middle-end/71606
	* fold-const.c (fold_convertible_p): As COMPLEX_TYPE
	folding produces SAVE_EXPRs, thus return false for the type.

gcc/testsuite/ChangeLog:

2016-06-22  Martin Liska  <mliska@suse.cz>

	* gcc.dg/torture/pr71606.c: New test.
---
 gcc/fold-const.c                       |  1 -
 gcc/testsuite/gcc.dg/torture/pr71606.c | 11 +++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/torture/pr71606.c

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 3b9500d..f5d634e 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -2192,7 +2192,6 @@ fold_convertible_p (const_tree type, const_tree arg)
 
     case REAL_TYPE:
     case FIXED_POINT_TYPE:
-    case COMPLEX_TYPE:
     case VECTOR_TYPE:
     case VOID_TYPE:
       return TREE_CODE (type) == TREE_CODE (orig);
diff --git a/gcc/testsuite/gcc.dg/torture/pr71606.c b/gcc/testsuite/gcc.dg/torture/pr71606.c
new file mode 100644
index 0000000..b0cc26a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr71606.c
@@ -0,0 +1,11 @@
+_Complex a;
+void fn1 ();
+
+int main () {
+  fn1 (a);
+  return 0;
+}
+
+void fn1 (__complex__ long double p1) {
+  __imag__ p1 = 6.0L;
+}
-- 
2.8.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]