From f0af4848ac40d2342743c9b16416310d61db85b5 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 15 Nov 2019 09:09:16 +0000 Subject: [PATCH] re PR tree-optimization/92039 (Spurious -Warray-bounds warnings building 32-bit glibc) 2019-11-15 Richard Biener PR tree-optimization/92039 PR tree-optimization/91975 * tree-ssa-loop-ivcanon.c (constant_after_peeling): Revert previous change, treat invariants consistently as non-constant. (tree_estimate_loop_size): Ternary ops with just the first op constant are not optimized away. * gcc.dg/tree-ssa/cunroll-2.c: Revert to state previous to unroller adjustment. * g++.dg/tree-ssa/ivopts-3.C: Likewise. From-SVN: r278281 --- gcc/ChangeLog | 9 +++++++++ gcc/testsuite/ChangeLog | 8 ++++++++ gcc/testsuite/g++.dg/tree-ssa/ivopts-3.C | 6 ++---- gcc/testsuite/gcc.dg/tree-ssa/cunroll-2.c | 4 ++-- gcc/tree-ssa-loop-ivcanon.c | 10 ++++++---- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6810dfb194b..ca1c5ac9744 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2019-11-15 Richard Biener + + PR tree-optimization/92039 + PR tree-optimization/91975 + * tree-ssa-loop-ivcanon.c (constant_after_peeling): Revert + previous change, treat invariants consistently as non-constant. + (tree_estimate_loop_size): Ternary ops with just the first op + constant are not optimized away. + 2019-11-15 Jakub Jelinek * gimplify.c (gimplify_call_expr): Don't call diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6d7a132f08f..e537e5d6cad 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2019-11-15 Richard Biener + + PR tree-optimization/92039 + PR tree-optimization/91975 + * gcc.dg/tree-ssa/cunroll-2.c: Revert to state previous to + unroller adjustment. + * g++.dg/tree-ssa/ivopts-3.C: Likewise. + 2019-11-15 Jakub Jelinek * c-c++-common/gomp/declare-variant-13.c: New test. diff --git a/gcc/testsuite/g++.dg/tree-ssa/ivopts-3.C b/gcc/testsuite/g++.dg/tree-ssa/ivopts-3.C index b0da5e68abc..cbb6c850baa 100644 --- a/gcc/testsuite/g++.dg/tree-ssa/ivopts-3.C +++ b/gcc/testsuite/g++.dg/tree-ssa/ivopts-3.C @@ -70,8 +70,6 @@ int main ( int , char** ) { return 0; } -// Verify that on x86_64 and i?86 we unroll the innsermost loop and -// use three IVs for the then innermost loop +// Verify that on x86_64 and i?86 we use a single IV for the innermost loop -// { dg-final { scan-tree-dump "Selected IV set for loop \[0-9\]* at \[^ \]*:63, 127 avg niters, 3 IVs" "ivopts" { target x86_64-*-* i?86-*-* } } } -// { dg-final { scan-tree-dump-not "Selected IV set for loop \[0-9\]* at \[^ \]*:64" "ivopts" { target x86_64-*-* i?86-*-* } } } +// { dg-final { scan-tree-dump "Selected IV set for loop \[0-9\]* at \[^ \]*:64, 3 avg niters, 1 IVs" "ivopts" { target x86_64-*-* i?86-*-* } } } diff --git a/gcc/testsuite/gcc.dg/tree-ssa/cunroll-2.c b/gcc/testsuite/gcc.dg/tree-ssa/cunroll-2.c index ae3fec99749..b1d1c7d3d85 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/cunroll-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/cunroll-2.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O3 -fdump-tree-cunrolli-details" } */ +/* { dg-options "-O3 -fdump-tree-cunroll-details" } */ int a[2]; int test2 (void); void @@ -14,4 +14,4 @@ test(int c) } } /* We are not able to get rid of the final conditional because the loop has two exits. */ -/* { dg-final { scan-tree-dump "loop with 2 iterations completely unrolled" "cunrolli"} } */ +/* { dg-final { scan-tree-dump "loop with 1 iterations completely unrolled" "cunroll"} } */ diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c index c2543eec925..63c2c6bdb08 100644 --- a/gcc/tree-ssa-loop-ivcanon.c +++ b/gcc/tree-ssa-loop-ivcanon.c @@ -163,7 +163,7 @@ struct loop_size static bool constant_after_peeling (tree op, gimple *stmt, class loop *loop) { - if (is_gimple_min_invariant (op)) + if (CONSTANT_CLASS_P (op)) return true; /* We can still fold accesses to constant arrays when index is known. */ @@ -195,8 +195,9 @@ constant_after_peeling (tree op, gimple *stmt, class loop *loop) /* Induction variables are constants when defined in loop. */ if (loop_containing_stmt (stmt) != loop) return false; - tree ev = instantiate_parameters (loop, analyze_scalar_evolution (loop, op)); - if (chrec_contains_undetermined (ev)) + tree ev = analyze_scalar_evolution (loop, op); + if (chrec_contains_undetermined (ev) + || chrec_contains_symbols (ev)) return false; return true; } @@ -293,7 +294,8 @@ tree_estimate_loop_size (class loop *loop, edge exit, edge edge_to_cancel, stmt, loop) && (gimple_assign_rhs_class (stmt) != GIMPLE_BINARY_RHS || constant_after_peeling (gimple_assign_rhs2 (stmt), - stmt, loop))) + stmt, loop)) + && gimple_assign_rhs_class (stmt) != GIMPLE_TERNARY_RHS) { size->constant_iv = true; if (dump_file && (dump_flags & TDF_DETAILS))