[Bug tree-optimization/90866] [10 Regression] ICE in fold_binary_loc, at fold-const.c:9827 since r272197

2019-06-13 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90866

Martin Sebor  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=90662
 Resolution|--- |FIXED

--- Comment #11 from Martin Sebor  ---
Patch committed in r272281.

[Bug tree-optimization/90866] [10 Regression] ICE in fold_binary_loc, at fold-const.c:9827 since r272197

2019-06-13 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90866

Martin Sebor  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #10 from Martin Sebor  ---
Patch: https://gcc.gnu.org/ml/gcc-patches/2019-06/msg00793.html

[Bug tree-optimization/90866] [10 Regression] ICE in fold_binary_loc, at fold-const.c:9827 since r272197

2019-06-13 Thread ktkachov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90866

--- Comment #9 from ktkachov at gcc dot gnu.org ---
Here's another one since my reducer finished :)
struct {
  int a[0];
} b;

int c;
int d[0];

void e() {
  b.a[c] = d[c + 1];
  b.a[c + 1] = d[c];
}

-O3 needed on an aarch64 target

[Bug tree-optimization/90866] [10 Regression] ICE in fold_binary_loc, at fold-const.c:9827 since r272197

2019-06-13 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90866

Martin Sebor  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |msebor at gcc dot 
gnu.org

--- Comment #8 from Martin Sebor  ---
Thanks for all the small test cases!

[Bug tree-optimization/90866] [10 Regression] ICE in fold_binary_loc, at fold-const.c:9827 since r272197

2019-06-13 Thread ktkachov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90866

ktkachov at gcc dot gnu.org changed:

   What|Removed |Added

 CC||ktkachov at gcc dot gnu.org

--- Comment #7 from ktkachov at gcc dot gnu.org ---
I also see this when building 502.gcc_r from SPEC

[Bug tree-optimization/90866] [10 Regression] ICE in fold_binary_loc, at fold-const.c:9827 since r272197

2019-06-13 Thread dimhen at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90866

--- Comment #6 from Dmitry G. Dyachenko  ---
(In reply to Dmitry G. Dyachenko from comment #5)
> $ cat x.i
> typedef enum { a } b;
> typedef struct {
>   int c[0];
> } d;
> typedef struct {
>   int *data;
> } e;
> typedef struct {
>   e buffer;
> } f;
> int g, h;
> int i();
> int i(f *j, d *k, b l, int m) {
>   if (l)
> if (m) {
>   h = j->buffer.data[0];
>   k->c[g] = k->c[g] * 8;
> }
>   return 0;
> 

add missed }

$ cat x.i
$ cat x.i
typedef enum { a } b;
typedef struct {
  int c[0];
} d;
typedef struct {
  int *data;
} e;
typedef struct {
  e buffer;
} f;
int g, h;
int i();
int i(f *j, d *k, b l, int m) {
  if (l)
if (m) {
  h = j->buffer.data[0];
  k->c[g] = k->c[g] * 8;
}
  return 0;
}

[Bug tree-optimization/90866] [10 Regression] ICE in fold_binary_loc, at fold-const.c:9827 since r272197

2019-06-13 Thread dimhen at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90866

--- Comment #5 from Dmitry G. Dyachenko  ---
$ cat x.i
typedef enum { a } b;
typedef struct {
  int c[0];
} d;
typedef struct {
  int *data;
} e;
typedef struct {
  e buffer;
} f;
int g, h;
int i();
int i(f *j, d *k, b l, int m) {
  if (l)
if (m) {
  h = j->buffer.data[0];
  k->c[g] = k->c[g] * 8;
}
  return 0;


$ gcc -fpreprocessed -O2 -fsanitize=thread -c x.i
during GIMPLE pass: strlen
x.i: In function ‘i’:
x.i:13:5: internal compiler error: in fold_binary_loc, at fold-const.c:9827
   13 | int i(f *j, d *k, b l, int m) {
  | ^
0x667691 fold_binary_loc(unsigned int, tree_code, tree_node*, tree_node*,
tree_node*)
/home/dimhen/src/gcc_current/gcc/fold-const.c:9827
0xcc9bed fold_build2_loc(unsigned int, tree_code, tree_node*, tree_node*,
tree_node*)
/home/dimhen/src/gcc_current/gcc/fold-const.c:12338
0x11b4a62 get_stridx
/home/dimhen/src/gcc_current/gcc/tree-ssa-strlen.c:327
0x11b4a62 get_stridx
/home/dimhen/src/gcc_current/gcc/tree-ssa-strlen.c:293
0x11bb65c strlen_check_and_optimize_stmt
/home/dimhen/src/gcc_current/gcc/tree-ssa-strlen.c:3721
0x11bb65c strlen_dom_walker::before_dom_children(basic_block_def*)
/home/dimhen/src/gcc_current/gcc/tree-ssa-strlen.c:4009
0x18dfca2 dom_walker::walk(basic_block_def*)
/home/dimhen/src/gcc_current/gcc/domwalk.c:312
0x11b0ea0 execute
/home/dimhen/src/gcc_current/gcc/tree-ssa-strlen.c:4089
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug tree-optimization/90866] [10 Regression] ICE in fold_binary_loc, at fold-const.c:9827 since r272197

2019-06-13 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90866

--- Comment #4 from Richard Biener  ---
(In reply to Martin Liška from comment #3)
> So my patch survives bootstrap and regression tests, can you please Martin
> take the issue?
> 
> Patch candidate:
> diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c
> index 944650cecd5..a9b1147a2e7 100644
> --- a/gcc/tree-ssa-strlen.c
> +++ b/gcc/tree-ssa-strlen.c
> @@ -324,7 +324,7 @@ get_stridx (tree exp)
> off = TREE_OPERAND (ptr, 1);
> /* Scale the array index by the size of the element
>type (normally 1 for char).  */
> -   off = fold_build2 (MULT_EXPR, TREE_TYPE (off), off,
> +   off = fold_build2 (MULT_EXPR, TREE_TYPE (eltsize), off,
>eltsize);
> ptr = TREE_OPERAND (ptr, 0);
>   }

Of course this shouldn't make a difference.  The issue is likely a
type mismatch and 'off' being a pointer type?  Probably
mem_ref_offset () should be used to extract it.

[Bug tree-optimization/90866] [10 Regression] ICE in fold_binary_loc, at fold-const.c:9827 since r272197

2019-06-13 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90866

Martin Liška  changed:

   What|Removed |Added

 Status|ASSIGNED|NEW
   Assignee|marxin at gcc dot gnu.org  |unassigned at gcc dot 
gnu.org

--- Comment #3 from Martin Liška  ---
So my patch survives bootstrap and regression tests, can you please Martin take
the issue?

Patch candidate:
diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c
index 944650cecd5..a9b1147a2e7 100644
--- a/gcc/tree-ssa-strlen.c
+++ b/gcc/tree-ssa-strlen.c
@@ -324,7 +324,7 @@ get_stridx (tree exp)
  off = TREE_OPERAND (ptr, 1);
  /* Scale the array index by the size of the element
 type (normally 1 for char).  */
- off = fold_build2 (MULT_EXPR, TREE_TYPE (off), off,
+ off = fold_build2 (MULT_EXPR, TREE_TYPE (eltsize), off,
 eltsize);
  ptr = TREE_OPERAND (ptr, 0);
}

[Bug tree-optimization/90866] [10 Regression] ICE in fold_binary_loc, at fold-const.c:9827 since r272197

2019-06-13 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90866

Martin Liška  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |marxin at gcc dot 
gnu.org

[Bug tree-optimization/90866] [10 Regression] ICE in fold_binary_loc, at fold-const.c:9827 since r272197

2019-06-13 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90866

--- Comment #2 from Martin Liška  ---
I'm testing a patch candidate..

[Bug tree-optimization/90866] [10 Regression] ICE in fold_binary_loc, at fold-const.c:9827 since r272197

2019-06-13 Thread dcb314 at hotmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90866

David Binderman  changed:

   What|Removed |Added

 CC||dcb314 at hotmail dot com

--- Comment #1 from David Binderman  ---
I also see this crash, when bootstrapping the compiler with -O3.

 ../../../trunk/libgcc/libgcc2.c
during GIMPLE pass: strlen
../../../trunk/libgcc/unwind-dw2.c: In function ‘execute_stack_op’:
../../../trunk/libgcc/unwind-dw2.c:526:1: internal compiler error: in
fold_binary_loc, at fold-const.c:9827

[Bug tree-optimization/90866] [10 Regression] ICE in fold_binary_loc, at fold-const.c:9827 since r272197

2019-06-13 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90866

Martin Liška  changed:

   What|Removed |Added

   Priority|P3  |P1
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-06-13
  Known to work||9.1.0
   Target Milestone|--- |10.0
 Ever confirmed|0   |1
  Known to fail||10.0