https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90006

            Bug ID: 90006
           Summary: gcc loops indefinitely around
                    vect_get_constant_vectors on -O2 -ftree-slp-vectorize
                    -fno-math-errno
           Product: gcc
           Version: 8.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slyfox at inbox dot ru
  Target Milestone: ---

Compiler looping on libavcodec/pngenc.c (ffmpeg-4.1) is originally reported atn
https://bugs.gentoo.org/682694.

Here is a minimal reproducer against gcc-8.3.0:

// $ cat bug.c
// Now to reproduce:
// $ /usr/bin/x86_64-pc-linux-gnu-gcc -m32 -O2 -ftree-slp-vectorize
-fno-math-errno -c bug.c -o bug.o -Wall

long int lrint(double x);

int a, b;
union c {
  int d;
};

int e() {
  int f, g, h;
  long i, j, k;
  double l, m = b = lrint(0.3127);
  a = b >> 16 >> 8 & 255;
  ((union c *)e)->d = a;
  k = m;
  h = k >> 16 >> 8 & 255;
  ((union c *)(e + 4))->d = h;
  j = lrint(l);
  g = j >> 16 >> 8 & 255;
  ((union c *)(e + 8))->d = g;
  i = lrint(0.292);
  f = i >> 16 >> 8 & 255;
  ((union c *)(e + 12))->d = f;
  return 0;
}

$ LANG=C /usr/bin/x86_64-pc-linux-gnu-gcc -m32 -O2 -ftree-slp-vectorize
-fno-math-errno -c bug.c -o bug.o -Wall
bug.c: In function 'e':
bug.c:20:7: warning: 'l' is used uninitialized in this function
[-Wuninitialized]
   j = lrint(l);
       ^~~~~~~~
<hung>

'perf' says looping happens in 'vect_get_constant_vectors':

vec<tree_node*, va_heap, vl_ptr>::length (this=0x7fff0b1593b0) at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/vec.h:1303
1303      unsigned length (void) const
(gdb) bt
#0  vec<tree_node*, va_heap, vl_ptr>::length (this=0x7fff0b1593b0) at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/vec.h:1303
#1  vect_get_constant_vectors (op=<optimized out>, slp_node=0x1eaade0,
vec_oprnds=0x7fff0b1593b0, op_num=0, number_of_vectors=1)
    at /usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/tree-vect-slp.c:3741
#2  0x0000000000c74ef8 in vect_get_slp_defs (ops=ops@entry=...,
slp_node=slp_node@entry=0x1eaade0, vec_oprnds=vec_oprnds@entry=0x7fff0b1594b8)
    at /usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/tree-vect-slp.c:3877
#3  0x0000000000c3cfb6 in vectorizable_call (gs=0x7f2fdde4e3f0,
gsi=0x7fff0b159670, vec_stmt=0x7fff0b159590, slp_node=0x1eaade0)
    at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/tree-vect-stmts.c:3387
#4  0x0000000000c4dfaf in vect_transform_stmt (stmt=stmt@entry=0x7f2fdde4e3f0,
gsi=gsi@entry=0x7fff0b159670, grouped_store=grouped_store@entry=0x7fff0b15966f, 
    slp_node=slp_node@entry=0x1eaade0, slp_node_instance=<optimized out>) at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/tree-vect-stmts.c:9557
#5  0x0000000000c78a05 in vect_schedule_slp_instance (node=0x1eaade0,
instance=<optimized out>, bst_map=<optimized out>)
    at /usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/tree-vect-slp.c:4214
#6  0x0000000000c787f4 in vect_schedule_slp_instance (node=0x1ea9830,
instance=0x1ea7060, bst_map=0x1eab2c0) at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/tree-vect-slp.c:4104
#7  0x0000000000c787f4 in vect_schedule_slp_instance (node=0x1ea9870,
instance=0x1ea7060, bst_map=0x1eab2c0) at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/tree-vect-slp.c:4104
#8  0x0000000000c787f4 in vect_schedule_slp_instance (node=0x1ea98b0,
instance=0x1ea7060, bst_map=0x1eab2c0) at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/tree-vect-slp.c:4104
#9  0x0000000000c787f4 in vect_schedule_slp_instance (node=0x1ea98f0,
instance=0x1ea7060, bst_map=0x1eab2c0) at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/tree-vect-slp.c:4104
#10 0x0000000000c793cb in vect_schedule_slp (vinfo=0x1d05270) at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/tree-vect-slp.c:4283
#11 0x0000000000c7bbc4 in vect_slp_bb (bb=bb@entry=0x7f2fddd08270) at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/tree-vect-slp.c:3277
#12 0x0000000000c7d5a7 in (anonymous namespace)::pass_slp_vectorize::execute
(this=<optimized out>, fun=0x7f2fdde4c000)
    at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/tree-vectorizer.c:978
#13 0x000000000098ca57 in execute_one_pass (pass=0x1cf2ff0) at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/passes.c:2497
#14 0x000000000098d1c8 in execute_pass_list_1 (pass=0x1cf2ff0) at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/passes.c:2586
#15 0x000000000098d1da in execute_pass_list_1 (pass=0x1cf2f90) at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/passes.c:2587
#16 0x000000000098d1da in execute_pass_list_1 (pass=0x1cf1110) at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/passes.c:2587
#17 0x000000000098d219 in execute_pass_list (fn=0x7f2fdde4c000, pass=<optimized
out>) at /usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/passes.c:2597
#18 0x00000000006e4dbd in cgraph_node::expand (this=0x7f2fdde50000) at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/context.h:48
#19 0x00000000006e5e75 in expand_all_functions () at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/cgraphunit.c:2275
#20 symbol_table::compile (this=0x7f2fddd00100) at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/cgraphunit.c:2624
#21 0x00000000006e7bda in symbol_table::compile (this=0x7f2fddd00100) at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/cgraphunit.c:2717
#22 symbol_table::finalize_compilation_unit (this=0x7f2fddd00100) at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/cgraphunit.c:2717
#23 0x0000000000a4ffaa in compile_file () at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/toplev.c:480
#24 0x00000000005af413 in do_compile () at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/toplev.c:2136
#25 toplev::main (this=this@entry=0x7fff0b15aa36, argc=<optimized out>,
argc@entry=19, argv=<optimized out>, argv@entry=0x7fff0b15ab38)
    at /usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/toplev.c:2271
#26 0x00000000005b16cb in main (argc=19, argv=0x7fff0b15ab38) at
/usr/src/debug/sys-devel/gcc-8.3.0-r1/gcc-8.3.0/gcc/main.c:39

Reply via email to