public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH PR81744]Fix ICE by deep copying expression of loop's number of iterations
@ 2017-08-08 10:36 Bin Cheng
  2017-08-08 11:14 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Bin Cheng @ 2017-08-08 10:36 UTC (permalink / raw)
  To: gcc-patches; +Cc: nd

[-- Attachment #1: Type: text/plain, Size: 473 bytes --]

Hi,
This is an obvious patch.  It fixes ICE in PR81744 by deep copying expression
of loop's number of iterations.
Test result checked.  Is it OK?

Thanks,
bin
2017-08-07  Bin Cheng  <bin.cheng@arm.com>

	PR tree-optimization/81744
	* tree-predcom.c (prepare_finalizers_chain): Deep copy expr of
	loop's number of iterations.

gcc/testsuite/ChangeLog
2017-08-07  Bin Cheng  <bin.cheng@arm.com>

	PR tree-optimization/81744
	* gcc.dg/tree-ssa/pr81744.c: New.

[-- Attachment #2: pr81744.txt --]
[-- Type: text/plain, Size: 1054 bytes --]

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr81744.c b/gcc/testsuite/gcc.dg/tree-ssa/pr81744.c
new file mode 100644
index 0000000..b0f5d38f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr81744.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fno-tree-loop-vectorize -fno-tree-slp-vectorize -fno-inline -fdump-tree-pcom-details" } */
+
+typedef struct {
+  int a, b;
+} CompandSegment;
+int a;
+CompandSegment *b;
+void fn1() {
+  for (; a; a++)
+    b[a].a = b[a].b = b[a - 1].a = b[a - 1].b = 0;
+}
+/* { dg-final { scan-tree-dump-times "Store-stores chain" 2 "pcom"} } */
diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c
index 4538773..e7b10cb 100644
--- a/gcc/tree-predcom.c
+++ b/gcc/tree-predcom.c
@@ -2940,7 +2940,7 @@ prepare_finalizers_chain (struct loop *loop, chain_p chain)
 
       if (TREE_CODE (niters) != INTEGER_CST && TREE_CODE (niters) != SSA_NAME)
 	{
-	  niters = copy_node (niters);
+	  niters = unshare_expr (niters);
 	  niters = force_gimple_operand (niters, &stmts, true, NULL);
 	  if (stmts)
 	    {

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH PR81744]Fix ICE by deep copying expression of loop's number of iterations
  2017-08-08 10:36 [PATCH PR81744]Fix ICE by deep copying expression of loop's number of iterations Bin Cheng
@ 2017-08-08 11:14 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2017-08-08 11:14 UTC (permalink / raw)
  To: Bin Cheng; +Cc: gcc-patches, nd

On Tue, Aug 8, 2017 at 12:35 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> This is an obvious patch.  It fixes ICE in PR81744 by deep copying expression
> of loop's number of iterations.
> Test result checked.  Is it OK?

Ok.

Thanks,
Richard.

> Thanks,
> bin
> 2017-08-07  Bin Cheng  <bin.cheng@arm.com>
>
>         PR tree-optimization/81744
>         * tree-predcom.c (prepare_finalizers_chain): Deep copy expr of
>         loop's number of iterations.
>
> gcc/testsuite/ChangeLog
> 2017-08-07  Bin Cheng  <bin.cheng@arm.com>
>
>         PR tree-optimization/81744
>         * gcc.dg/tree-ssa/pr81744.c: New.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-08 11:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-08 10:36 [PATCH PR81744]Fix ICE by deep copying expression of loop's number of iterations Bin Cheng
2017-08-08 11:14 ` Richard Biener

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