[Bug tree-optimization/110280] internal compiler error: in const_unop, at fold-const.cc:1884

2023-06-17 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110280

Andrew Pinski  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=96463

--- Comment #9 from Andrew Pinski  ---
The creation of that VEC_PERM comes started at r13-1055-g494bec025002df422f2f
(aka PR 96463). 

The VEC_PERM match-and-simplify was not updated for the new semantics it seems
(it was added at r10-507-gebd733a78ccf ).

[Bug tree-optimization/110280] internal compiler error: in const_unop, at fold-const.cc:1884

2023-06-17 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110280

--- Comment #8 from Andrew Pinski  ---
In the original case FRE is trying to do the same thing as the reduced
testcase:
```
Successfully combined 4 partial definitions
Setting value number of _39 to { 0, 0, 0, 0 } (changed)
Value numbering stmt = _40 = VEC_PERM_EXPR <_39, _39, { 0, 1, 2, 3, ... }>;
Match-and-simplified VEC_PERM_EXPR <_39, _39, { 0, 1, 2, 3, ... }> to { 0, 0,
0, 0 }
RHS VEC_PERM_EXPR <_39, _39, { 0, 1, 2, 3, ... }> simplified to { 0, 0, 0, 0 }
Setting value number of _40 to { 0, 0, 0, 0 } (changed)
Value numbering stmt = lanes ={v} {CLOBBER(eol)};
Setting value number of .MEM_54 to .MEM_54 (changed)
Value numbering stmt = _41 = [vec_unpack_lo_expr] _40;
```

[Bug tree-optimization/110280] internal compiler error: in const_unop, at fold-const.cc:1884

2023-06-17 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110280

--- Comment #7 from Andrew Pinski  ---
I think this part of match is incorrect:
(if (sel.series_p (0, 1, 0, 1))
 { op0; }
 (if (sel.series_p (0, 1, nelts, 1))
  { op1; }

This is only true if type == TREE_TYPE (op0) (well compatible) ...

[Bug tree-optimization/110280] internal compiler error: in const_unop, at fold-const.cc:1884

2023-06-17 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110280

--- Comment #6 from Andrew Pinski  ---
Match-and-simplified VEC_PERM_EXPR <_10, _10, { 0, 1, 2, 3, ... }> to { 0, 0,
0, 0 }


Ok, that is wrong ...

[Bug tree-optimization/110280] internal compiler error: in const_unop, at fold-const.cc:1884

2023-06-17 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110280

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |13.2
  Known to fail||13.1.0

--- Comment #5 from Andrew Pinski  ---
First reduced testcase with the same ICE:
```
#include "arm_sve.h"
auto l() {
  svuint32_t ttt;
  {
alignas(16) const unsigned int lanes[4] = {0, 0, 0, 0};
ttt = svld1rq_u32(svptrue_b8(), lanes);
  }
  return svunpklo_u64 (ttt);
}
```

Another reduced testcase with a related ICE:
```
#include "arm_sve.h"
svuint32_t l() {
  alignas(16) const unsigned int lanes[4] = {0, 0, 0, 0};
  return svld1rq_u32(svptrue_b8(), lanes);
}
```

For the first one, we have:
```
  lanes[0] = 0;
  lanes[1] = 0;
  lanes[2] = 0;
  lanes[3] = 0;
  _10 = MEM  [(unsigned int * {ref-all})&lanes];
  ttt_7 = VEC_PERM_EXPR <_10, _10, { 0, 1, 2, 3, ... }>;
  lanes ={v} {CLOBBER(eol)};
  _9 = [vec_unpack_lo_expr] ttt_7;
```
The ICE is on simplifying _9.
The second one we have a similar thing except no vec_unpack_lo_expr there.

I suspect it is the simplification of the VEC_PERM which is causing the issue
rather than vec_unpack_lo_expr directly.
And dealing with how _10 is generated inside fre to a vector.

[Bug tree-optimization/110280] internal compiler error: in const_unop, at fold-const.cc:1884

2023-06-16 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110280

--- Comment #4 from Andrew Pinski  ---
(gdb) p debug_gimple_stmt(stmt)
_41 = [vec_unpack_lo_expr] _40;

[Bug tree-optimization/110280] internal compiler error: in const_unop, at fold-const.cc:1884

2023-06-16 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110280

--- Comment #3 from Andrew Pinski  ---
#6  0x0087710b in const_unop (code=VEC_UNPACK_LO_EXPR, type=, arg0=) at ../../gcc/fold-const.cc:1954
1954gcc_assert (known_eq (out_nelts, TYPE_VECTOR_SUBPARTS (type)));