From c0d4fec75c36e60c0305c585310a8feb89a04a1d Mon Sep 17 00:00:00 2001 From: Kyrylo Tkachov Date: Mon, 9 Jan 2017 09:42:10 +0000 Subject: [PATCH] [tree-ssa-address] Avoid creating non-canonical RTL in gen_addr_rtx * tree-ssa-address.c (gen_addr_rtx): Don't handle index if it is const0_rtx. * gcc.dg/20161219.c: New test. From-SVN: r244219 --- gcc/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/20161219.c | 30 ++++++++++++++++++++++++++++++ gcc/tree-ssa-address.c | 2 +- 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/20161219.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 96f3c2e615d..540c2bdf75f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-01-09 Kyrylo Tkachov + + * tree-ssa-address.c (gen_addr_rtx): Don't handle index if it + is const0_rtx. + 2017-01-09 Richard Biener PR tree-optimization/78997 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 053d2cf76f1..14e24a8c3c1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-01-09 Kyrylo Tkachov + + * gcc.dg/20161219.c: New test. + 2017-01-09 Richard Biener PR tree-optimization/78997 diff --git a/gcc/testsuite/gcc.dg/20161219.c b/gcc/testsuite/gcc.dg/20161219.c new file mode 100644 index 00000000000..93ea8d2364d --- /dev/null +++ b/gcc/testsuite/gcc.dg/20161219.c @@ -0,0 +1,30 @@ +/* { dg-do assemble } */ +/* { dg-options "-O1 -w" } */ + +static long long a[9]; +int b, c, d, e, g; + +static int +fn1 (int *p1) +{ + b = 1; + for (; b >= 0; b--) + { + d = 0; + for (;; d++) + { + e && (a[d] = 0); + if (*p1) + break; + c = (int) a; + } + } + return 0; +} + +int +main () +{ + int f = fn1 ((int *) f); + return f; +} diff --git a/gcc/tree-ssa-address.c b/gcc/tree-ssa-address.c index 3e3cad150b6..8d46a3e6733 100644 --- a/gcc/tree-ssa-address.c +++ b/gcc/tree-ssa-address.c @@ -115,7 +115,7 @@ gen_addr_rtx (machine_mode address_mode, if (offset_p) *offset_p = NULL; - if (index) + if (index && index != const0_rtx) { act_elem = index; if (step) -- 2.30.2