[Bug tree-optimization/83857] [8 Regression] internal compiler error: in exact_div, at poly-int.h:2139

2018-01-16 Thread rsandifo at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83857

rsandifo at gcc dot gnu.org  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #7 from rsandifo at gcc dot gnu.org  
---
Fixed.

[Bug tree-optimization/83857] [8 Regression] internal compiler error: in exact_div, at poly-int.h:2139

2018-01-16 Thread rsandifo at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83857

--- Comment #6 from rsandifo at gcc dot gnu.org  
---
Author: rsandifo
Date: Tue Jan 16 15:13:32 2018
New Revision: 256747

URL: https://gcc.gnu.org/viewcvs?rev=256747=gcc=rev
Log:
Two fixes for live-out SLP inductions (PR 83857)

vect_analyze_loop_operations was calling vectorizable_live_operation
for all live-out phis, which led to a bogus ncopies calculation in
the pure SLP case.  I think v_a_l_o should only be passing phis
that are vectorised using normal loop vectorisation, since
vect_slp_analyze_node_operations handles the SLP side (and knows
the correct slp_index and slp_node arguments to pass in, via
vect_analyze_stmt).

With that fixed we hit an older bug that vectorizable_live_operation
didn't handle live-out SLP inductions.  Fixed by using gimple_phi_result
rather than gimple_get_lhs for phis.

2018-01-16  Richard Sandiford  

gcc/
PR tree-optimization/83857
* tree-vect-loop.c (vect_analyze_loop_operations): Don't call
vectorizable_live_operation for pure SLP statements.
(vectorizable_live_operation): Handle PHIs.

gcc/testsuite/
PR tree-optimization/83857
* gcc.dg/vect/pr83857.c: New test.

Added:
trunk/gcc/testsuite/gcc.dg/vect/pr83857.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-vect-loop.c

[Bug tree-optimization/83857] [8 Regression] internal compiler error: in exact_div, at poly-int.h:2139

2018-01-15 Thread rsandifo at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83857

--- Comment #5 from rsandifo at gcc dot gnu.org  
---
Slightly reduced testcase:

f (double *x, double y)
{
  double a = 0;
  for (int i = 0; i < 100; ++i)
{
  a += y;
  x[i * 2] += a;
  x[i * 2 + 1] += a;
}
  return a - y;
}

The problem is that we need the phi to be treated as an SLP operation
when calculating ncopies.

[Bug tree-optimization/83857] [8 Regression] internal compiler error: in exact_div, at poly-int.h:2139

2018-01-15 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83857

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek  ---
This testcase started to ICE (segfault) with r248909,
cc1plus.252763: internal compiler error: Segmentation fault
0x1192507 crash_signal
../../gcc/toplev.c:341
0xde94b5 handled_component_p
../../gcc/tree.h:4450
0xdf9254 maybe_canonicalize_mem_ref_addr
../../gcc/gimple-fold.c:4306
0xdf9ab5 fold_stmt_1
../../gcc/gimple-fold.c:4405
0xdfacac fold_stmt(gimple_stmt_iterator*)
../../gcc/gimple-fold.c:4733
starting with r252764 it instead ICEs:
pr83857.C:15:1: internal compiler error: in vect_get_num_copies, at
tree-vectorizer.h:1088
and finally starting with r256126 it ICEs in exact_div, but in the same spot:
pr83857.C:15:1: internal compiler error: in exact_div, at poly-int.h:2139
0x15189bc vect_get_num_copies
../../gcc/tree-vectorizer.h:1120
0x152b901 vectorizable_live_operation(gimple*, gimple_stmt_iterator*,
_slp_tree*, int, gimple**)
../../gcc/tree-vect-loop.c:7124
0x151d04d vect_analyze_loop_operations
../../gcc/tree-vect-loop.c:1740

[Bug tree-optimization/83857] [8 Regression] internal compiler error: in exact_div, at poly-int.h:2139

2018-01-15 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83857

--- Comment #3 from Jakub Jelinek  ---
Reduced testcase with -Ofast:
template  struct C {
  typedef int D[N];
  static int  (D x, int y) { return x[y]; }
};
template  struct A {
  typedef C H;
  typename H::D k;
  int [](long x) { return H::foo (k, x); }
};
template  void bar (T);

float v;

int
main ()
{
  constexpr int n = 1 << 8;
  A o;
  auto load = [&](int i, float q) { o[i] = q;
for (int j = 1; j < 8; ++j)
  o[i + j] = o[i + j - 1]; };
  for (float p = v; p;)
for (auto j = 0; j < n; j += 8)
  {
p += 4.e7f;
load (j, p);
  }
  bar (o);
}

[Bug tree-optimization/83857] [8 Regression] internal compiler error: in exact_div, at poly-int.h:2139

2018-01-15 Thread rsandifo at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83857

rsandifo at gcc dot gnu.org  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2018-01-15
   Assignee|unassigned at gcc dot gnu.org  |rsandifo at gcc dot 
gnu.org
 Ever confirmed|0   |1

[Bug tree-optimization/83857] [8 Regression] internal compiler error: in exact_div, at poly-int.h:2139

2018-01-15 Thread vincenzo.innocente at cern dot ch
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83857

--- Comment #2 from vincenzo Innocente  ---
(In reply to Richard Biener from comment #1)
> I've seen a similar bug so maybe fixed already.
if the similar bug is #83753 it is looks "fixed" in the version I tested
(at least /gcc/testsuite/gcc.dg/torture/pr83753.c is present)

[Bug tree-optimization/83857] [8 Regression] internal compiler error: in exact_div, at poly-int.h:2139

2018-01-15 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83857

Richard Biener  changed:

   What|Removed |Added

 CC||rsandifo at gcc dot gnu.org
   Target Milestone|--- |8.0
Summary|[ICE] internal compiler |[8 Regression] internal
   |error: in exact_div, at |compiler error: in
   |poly-int.h:2139 |exact_div, at
   ||poly-int.h:2139

--- Comment #1 from Richard Biener  ---
I've seen a similar bug so maybe fixed already.