Message ID | DB5PR0801MB27422C1316E0F98D2CA9CB22E7B20@DB5PR0801MB2742.eurprd08.prod.outlook.com |
---|---|
State | New |
Headers | show |
On Mon, Jul 31, 2017 at 4:14 PM, Bin Cheng <Bin.Cheng@arm.com> wrote: > Hi, > This simple patch fixes the ICE by rewriting into loop closed ssa form in case > of any store-store chain. We maybe able to avoid that for some cases that > eliminated stores only store loop invariant values, but only with more checks > when inserting final store instructions. > Bootstrap and test on x86_64 and AArch64 ongoing. Is it OK? Ok. Thanks, Richard. > Thanks, > bin > 2017-07-31 Bin Cheng <bin.cheng@arm.com> > > PR tree-optimization/81627 > * tree-predcom.c (prepare_finalizers): Always rewrite into loop > closed ssa form for store-store chain. > > gcc/testsuite/ChangeLog > 2017-07-31 Bin Cheng <bin.cheng@arm.com> > > PR tree-optimization/81627 > * gcc.dg/tree-ssa/pr81627.c: New.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr81627.c b/gcc/testsuite/gcc.dg/tree-ssa/pr81627.c new file mode 100755 index 0000000..7421c49 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr81627.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -fno-tree-loop-vectorize -fdump-tree-pcom-details" } */ + +int a, b, c, d[6], e = 3, f; + +void abort (void); +void fn1 () +{ + for (b = 1; b < 5; b++) + { + for (c = 0; c < 5; c++) + d[b] = e; + if (a) + f++; + d[b + 1] = 1; + } +} + +int main () +{ + fn1 (); + if (d[0] != 0 || d[1] != 3 || d[2] != 3 + || d[3] != 3 || d[4] != 3 || d[5] != 1) + abort (); + + return 0; +} +/* { dg-final { scan-tree-dump-times "Store-stores chain" 1 "pcom" } } */ diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c index f7a57a4..4538773 100644 --- a/gcc/tree-predcom.c +++ b/gcc/tree-predcom.c @@ -2983,11 +2983,11 @@ prepare_finalizers (struct loop *loop, vec<chain_p> chains) if (prepare_finalizers_chain (loop, chain)) { i++; - /* We don't corrupt loop closed ssa form for store elimination - chain if eliminated stores only store loop invariant values - into memory. */ - if (!chain->inv_store_elimination) - loop_closed_ssa |= (!chain->inv_store_elimination); + /* Be conservative, assume loop closed ssa form is corrupted + by store-store chain. Though it's not always the case if + eliminated stores only store loop invariant values into + memory. */ + loop_closed_ssa = true; } else {
Hi, This simple patch fixes the ICE by rewriting into loop closed ssa form in case of any store-store chain. We maybe able to avoid that for some cases that eliminated stores only store loop invariant values, but only with more checks when inserting final store instructions. Bootstrap and test on x86_64 and AArch64 ongoing. Is it OK? Thanks, bin 2017-07-31 Bin Cheng <bin.cheng@arm.com> PR tree-optimization/81627 * tree-predcom.c (prepare_finalizers): Always rewrite into loop closed ssa form for store-store chain. gcc/testsuite/ChangeLog 2017-07-31 Bin Cheng <bin.cheng@arm.com> PR tree-optimization/81627 * gcc.dg/tree-ssa/pr81627.c: New. From d366015187de926a8fe3248325b229bed99b27b5 Mon Sep 17 00:00:00 2001 From: Bin Cheng <binche01@e108451-lin.cambridge.arm.com> Date: Mon, 31 Jul 2017 11:16:44 +0100 Subject: [PATCH 2/2] pr81627-20170731.txt --- gcc/testsuite/gcc.dg/tree-ssa/pr81627.c | 28 ++++++++++++++++++++++++++++ gcc/tree-predcom.c | 10 +++++----- 2 files changed, 33 insertions(+), 5 deletions(-) create mode 100755 gcc/testsuite/gcc.dg/tree-ssa/pr81627.c