From bcfaa720a25d9f3bc760a993ee1d949f68e777ef Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 18 Dec 2017 08:35:23 +0000 Subject: [PATCH] re PR ipa/81877 (Incorrect results with lto and -fipa-cp and -fipa-cp-clone) 2017-12-18 Richard Biener PR tree-optimization/81877 * tree-ssa-loop-im.c (ref_indep_loop_p): Remove safelen parameters. (outermost_indep_loop): Adjust. (ref_indep_loop_p_1): Likewise. Remove safelen handling again. (can_sm_ref_p): Adjust. * g++.dg/torture/pr81877.C: New testcase. * g++.dg/vect/pr70729.cc: XFAIL. * g++.dg/vect/pr70729-nest.cc: XFAIL. From-SVN: r255776 --- gcc/ChangeLog | 8 ++++ gcc/testsuite/ChangeLog | 7 +++ gcc/testsuite/g++.dg/torture/pr81877.C | 22 ++++++++++ gcc/testsuite/g++.dg/vect/pr70729-nest.cc | 2 +- gcc/testsuite/g++.dg/vect/pr70729.cc | 2 +- gcc/tree-ssa-loop-im.c | 53 +++++------------------ 6 files changed, 49 insertions(+), 45 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr81877.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c9a5f2123a1..ab682443d3a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-12-18 Richard Biener + + PR tree-optimization/81877 + * tree-ssa-loop-im.c (ref_indep_loop_p): Remove safelen parameters. + (outermost_indep_loop): Adjust. + (ref_indep_loop_p_1): Likewise. Remove safelen handling again. + (can_sm_ref_p): Adjust. + 2017-12-18 Richard Biener PR middle-end/77291 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8fe9a88b33a..afcdd206d5f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2017-12-18 Richard Biener + + PR tree-optimization/81877 + * g++.dg/torture/pr81877.C: New testcase. + * g++.dg/vect/pr70729.cc: XFAIL. + * g++.dg/vect/pr70729-nest.cc: XFAIL. + 2017-12-18 Richard Biener PR middle-end/77291 diff --git a/gcc/testsuite/g++.dg/torture/pr81877.C b/gcc/testsuite/g++.dg/torture/pr81877.C new file mode 100644 index 00000000000..3d47d1bde09 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr81877.C @@ -0,0 +1,22 @@ +/* { dg-do run } */ + +void __attribute__((noipa)) g(int p, int *out) +{ + int x = 0, y; +#pragma GCC ivdep + for (int i = 0; i < 100; i++) + { + int &r = p ? x : y; + r = 42; + out[i] = x; + } +} + +int main() +{ + int out[100] = { 0 }; + g (1, out); + if (out[0] != 42) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/g++.dg/vect/pr70729-nest.cc b/gcc/testsuite/g++.dg/vect/pr70729-nest.cc index 931895b0a9c..0da0b4d73f5 100644 --- a/gcc/testsuite/g++.dg/vect/pr70729-nest.cc +++ b/gcc/testsuite/g++.dg/vect/pr70729-nest.cc @@ -76,4 +76,4 @@ void Ss::foo (int n) } } -// { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target x86_64-*-* i?86-*-* } } } +// { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { xfail *-*-* } } } diff --git a/gcc/testsuite/g++.dg/vect/pr70729.cc b/gcc/testsuite/g++.dg/vect/pr70729.cc index eac4b4bd75c..88d46553e5a 100644 --- a/gcc/testsuite/g++.dg/vect/pr70729.cc +++ b/gcc/testsuite/g++.dg/vect/pr70729.cc @@ -70,4 +70,4 @@ void Ss::foo (float *in, float w) } } -// { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target x86_64-*-* i?86-*-* } } } +// { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { xfail *-*-* } } } diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c index cf357cb8e2e..e0e1556516d 100644 --- a/gcc/tree-ssa-loop-im.c +++ b/gcc/tree-ssa-loop-im.c @@ -199,7 +199,7 @@ static struct static bitmap_obstack lim_bitmap_obstack; static obstack mem_ref_obstack; -static bool ref_indep_loop_p (struct loop *, im_mem_ref *, struct loop *); +static bool ref_indep_loop_p (struct loop *, im_mem_ref *); static bool ref_always_accessed_p (struct loop *, im_mem_ref *, bool); /* Minimum cost of an expensive expression. */ @@ -548,10 +548,10 @@ outermost_indep_loop (struct loop *outer, struct loop *loop, im_mem_ref *ref) aloop != loop; aloop = superloop_at_depth (loop, loop_depth (aloop) + 1)) if ((!ref->stored || !bitmap_bit_p (ref->stored, aloop->num)) - && ref_indep_loop_p (aloop, ref, loop)) + && ref_indep_loop_p (aloop, ref)) return aloop; - if (ref_indep_loop_p (loop, ref, loop)) + if (ref_indep_loop_p (loop, ref)) return loop; else return NULL; @@ -2150,20 +2150,13 @@ record_dep_loop (struct loop *loop, im_mem_ref *ref, bool stored_p) } /* Returns true if REF is independent on all other memory - references in LOOP. REF_LOOP is where REF is accessed, SAFELEN is the - safelen to apply. */ + references in LOOP. */ static bool -ref_indep_loop_p_1 (int safelen, struct loop *loop, im_mem_ref *ref, - bool stored_p, struct loop *ref_loop) +ref_indep_loop_p_1 (struct loop *loop, im_mem_ref *ref, bool stored_p) { stored_p |= (ref->stored && bitmap_bit_p (ref->stored, loop->num)); - if (loop->safelen > safelen - /* Check that REF is accessed inside LOOP. */ - && (loop == ref_loop || flow_loop_nested_p (loop, ref_loop))) - safelen = loop->safelen; - bool indep_p = true; bitmap refs_to_check; @@ -2174,32 +2167,6 @@ ref_indep_loop_p_1 (int safelen, struct loop *loop, im_mem_ref *ref, if (bitmap_bit_p (refs_to_check, UNANALYZABLE_MEM_ID)) indep_p = false; - else if (safelen > 1) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file,"REF is independent due to safelen %d\n", - safelen); - print_generic_expr (dump_file, ref->mem.ref, TDF_SLIM); - fprintf (dump_file, "\n"); - } - - /* We need to recurse to properly handle UNANALYZABLE_MEM_ID. */ - struct loop *inner = loop->inner; - while (inner) - { - if (!ref_indep_loop_p_1 (safelen, inner, ref, stored_p, ref_loop)) - { - indep_p = false; - break; - } - inner = inner->next; - } - - /* Avoid caching here as safelen depends on context and refs - are shared between different contexts. */ - return indep_p; - } else { if (bitmap_bit_p (&ref->indep_loop, LOOP_DEP_BIT (loop->num, stored_p))) @@ -2210,7 +2177,7 @@ ref_indep_loop_p_1 (int safelen, struct loop *loop, im_mem_ref *ref, struct loop *inner = loop->inner; while (inner) { - if (!ref_indep_loop_p_1 (safelen, inner, ref, stored_p, ref_loop)) + if (!ref_indep_loop_p_1 (inner, ref, stored_p)) { indep_p = false; break; @@ -2264,14 +2231,14 @@ ref_indep_loop_p_1 (int safelen, struct loop *loop, im_mem_ref *ref, } /* Returns true if REF is independent on all other memory references in - LOOP. REF_LOOP is the loop where REF is accessed. */ + LOOP. */ static bool -ref_indep_loop_p (struct loop *loop, im_mem_ref *ref, struct loop *ref_loop) +ref_indep_loop_p (struct loop *loop, im_mem_ref *ref) { gcc_checking_assert (MEM_ANALYZABLE (ref)); - return ref_indep_loop_p_1 (0, loop, ref, false, ref_loop); + return ref_indep_loop_p_1 (loop, ref, false); } /* Returns true if we can perform store motion of REF from LOOP. */ @@ -2307,7 +2274,7 @@ can_sm_ref_p (struct loop *loop, im_mem_ref *ref) /* And it must be independent on all other memory references in LOOP. */ - if (!ref_indep_loop_p (loop, ref, loop)) + if (!ref_indep_loop_p (loop, ref)) return false; return true; -- 2.30.2