[Bug tree-optimization/70177] [6 Regression] ICE in extract_ops_from_tree starting with r233660

2016-04-06 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70177

--- Comment #8 from Richard Biener  ---
Author: rguenth
Date: Wed Apr  6 10:31:27 2016
New Revision: 234776

URL: https://gcc.gnu.org/viewcvs?rev=234776=gcc=rev
Log:
2016-04-06  Richard Biener  

Backport from mainline
2016-03-11  Jakub Jelinek  

PR tree-optimization/70177
* gimple-expr.h (extract_ops_from_tree_1): Renamed to ...
(extract_ops_from_tree): ... this.  In the 2 argument
overload remove _1 suffix.
* gimple-expr.c (extract_ops_from_tree_1): Renamed to ...
(extract_ops_from_tree): ... this.
* gimple.c (gimple_build_assign, gimple_assign_set_rhs_from_tree):
Adjust callers.
* tree-ssa-loop-niter.c (derive_constant_upper_bound): Likewise.
* tree-ssa-forwprop.c (defcodefor_name): Call 3 operand
extract_ops_from_tree instead of 2 operand one.

* gcc.dg/pr70177.c: New test.

Added:
branches/gcc-5-branch/gcc/testsuite/gcc.dg/pr70177.c
Modified:
branches/gcc-5-branch/gcc/ChangeLog
branches/gcc-5-branch/gcc/gimple-expr.c
branches/gcc-5-branch/gcc/gimple-expr.h
branches/gcc-5-branch/gcc/gimple.c
branches/gcc-5-branch/gcc/testsuite/ChangeLog
branches/gcc-5-branch/gcc/tree-ssa-forwprop.c
branches/gcc-5-branch/gcc/tree-ssa-loop-niter.c

[Bug tree-optimization/70177] [6 Regression] ICE in extract_ops_from_tree starting with r233660

2016-03-11 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70177

Jakub Jelinek  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #7 from Jakub Jelinek  ---
Fixed.

[Bug tree-optimization/70177] [6 Regression] ICE in extract_ops_from_tree starting with r233660

2016-03-11 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70177

--- Comment #6 from Jakub Jelinek  ---
Author: jakub
Date: Fri Mar 11 12:28:50 2016
New Revision: 234140

URL: https://gcc.gnu.org/viewcvs?rev=234140=gcc=rev
Log:
PR tree-optimization/70177
* gimple-expr.h (extract_ops_from_tree_1): Renamed to ...
(extract_ops_from_tree): ... this.  In the 2 argument
overload remove _1 suffix.
* gimple-expr.c (extract_ops_from_tree_1): Renamed to ...
(extract_ops_from_tree): ... this.
* gimple.c (gimple_build_assign, gimple_assign_set_rhs_from_tree):
Adjust callers.
* tree-ssa-loop-niter.c (derive_constant_upper_bound): Likewise.
* tree-ssa-forwprop.c (defcodefor_name): Call 3 operand
extract_ops_from_tree instead of 2 operand one.

* gcc.dg/pr70177.c: New test.

Added:
trunk/gcc/testsuite/gcc.dg/pr70177.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/gimple-expr.c
trunk/gcc/gimple-expr.h
trunk/gcc/gimple.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-ssa-forwprop.c
trunk/gcc/tree-ssa-loop-niter.c

[Bug tree-optimization/70177] [6 Regression] ICE in extract_ops_from_tree starting with r233660

2016-03-11 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70177

--- Comment #5 from Jakub Jelinek  ---
Created attachment 37933
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37933=edit
gcc6-pr70177.patch

Untested fix.  The questions about latent issues, where the upper bound
expression comes from and why it is so weird, remain.

[Bug tree-optimization/70177] [6 Regression] ICE in extract_ops_from_tree starting with r233660

2016-03-11 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70177

Richard Biener  changed:

   What|Removed |Added

 Blocks||68963

--- Comment #4 from Richard Biener  ---
Using extract_ops_from_tree_1 looks fine to me.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68963
[Bug 68963] [4.9/5 Regression] O3 vs. O2 discards part of loop and terminates
early

[Bug tree-optimization/70177] [6 Regression] ICE in extract_ops_from_tree starting with r233660

2016-03-10 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70177

--- Comment #3 from Jakub Jelinek  ---
Perhaps better testcase (-O2 again):

int b[128];

void
foo (int i, int j)
{
  int c, f, g, h;
  for (g = 0; g < 64; g++)
for (h = g, f = 0; f <= i; f++, h++)
  for (c = 0; c < j; c++)
b[h] = 0;
}

This one is well defined if ((j <= 0 && i <= INT_MAX - 63) || i <= 64) and
numbers of loop iterations are 64, min (i >= 0 ? i + 1 : 0, INT_MAX - 62), max
(j, 0).

[Bug tree-optimization/70177] [6 Regression] ICE in extract_ops_from_tree starting with r233660

2016-03-10 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70177

--- Comment #2 from Jakub Jelinek  ---
Though, that expression looks weird, on the testcase it is clear that if i is
>= 0 (not -1!), then c must be 0, because otherwise the innermost loop must
invoke undefined behavior, and deriving anything about number of iterations
from the b[h] = 0; assignment in the upper loop is wrong, because the innermost
loop can (and must be) iterated 0 times.

[Bug tree-optimization/70177] [6 Regression] ICE in extract_ops_from_tree starting with r233660

2016-03-10 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70177

Jakub Jelinek  changed:

   What|Removed |Added

   Keywords||ice-on-valid-code
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2016-03-10
   Target Milestone|--- |6.0
 Ever confirmed|0   |1

--- Comment #1 from Jakub Jelinek  ---
derive_constant_upper_bound is called with
i_11(D) >= -1 ? 126 - (unsigned int) i_11(D) : 127
and as it is a COND_EXPR, obviously calling it for the 2 operand
extract_ops_from_tree doesn't work.
Calling extract_ops_from_tree_1 of course fixes the ICE (why haven't we renamed
it to extract_ops_from_tree BTW and just use overloading?), though the question
is if we can't do better for the COND_EXPR (in that case we'd need to pass it
to the *_ops function and handle COND_EXPR in there).
But we don't even handle INTEGER_CST - variable.
It is a pitty we got COND_EXPR, instead of say MAX_EXPR <126 - (unsigned)
i_11(D), 127>.

--- gcc/tree-ssa-loop-niter.c.jj2016-02-24 14:52:16.0 +0100
+++ gcc/tree-ssa-loop-niter.c   2016-03-10 23:47:45.407770775 +0100
@@ -2742,9 +2742,9 @@ static widest_int
 derive_constant_upper_bound (tree val)
 {
   enum tree_code code;
-  tree op0, op1;
+  tree op0, op1, op2;

-  extract_ops_from_tree (val, , , );
+  extract_ops_from_tree_1 (val, , , , );
   return derive_constant_upper_bound_ops (TREE_TYPE (val), op0, code, op1);
 }

[Bug tree-optimization/70177] [6 Regression] ICE in extract_ops_from_tree starting with r233660

2016-03-10 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70177

Jakub Jelinek  changed:

   What|Removed |Added

   Priority|P3  |P1