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

            Bug ID: 84803
           Summary: ice from ifcvt_memrefs_wont_trap with -O3
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

Created attachment 43613
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43613&action=edit
C source code

The attached code, when compiled by recent gcc trunk and 
compiler flag -O3, does this:

$ ../results/bin/gcc -c -O3 bug420.c
during GIMPLE pass: ifcvt
n4.c: In function ‘setn1’:
n4.c:185:6: internal compiler error: in operator[], at vec.h:841
0x65f564 vec<data_reference*, va_heap, vl_embed>::operator[](unsigned int)
        ../../trunk/gcc/vec.h:841
0x65f564 vec<data_reference*, va_heap, vl_ptr>::operator[](unsigned int)
        ../../trunk/gcc/vec.h:1326
0x65f564 ifcvt_memrefs_wont_trap
        ../../trunk/gcc/tree-if-conv.c:868
0x65f564 if_convertible_gimple_assign_stmt_p
        ../../trunk/gcc/tree-if-conv.c:1001

$ ../results/bin/gcc -v
Using built-in specs.
COLLECT_GCC=../results/bin/gcc
COLLECT_LTO_WRAPPER=/home/dcb/gcc/results.258387/libexec/gcc/x86_64-pc-linux-gnu/8.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../trunk/configure --prefix=/home/dcb/gcc/results.258387
--disable-multilib --disable-werror --enable-checking=df,extra,fold,rtl,yes
--enable-languages=c,c++,fortran
Thread model: posix
gcc version 8.0.1 20180309 (experimental) (GCC) 
$

Further checking suggests that the bug exists sometime before revision 257000

 $ for i in ../results.257*/bin/gcc; do echo $i; $i -c -O3 bug420.c ; done 
../results.257009/bin/gcc
==12304== Invalid read of size 8
==12304==    at 0xA869AD: ifcvt_memrefs_wont_trap (tree-if-conv.c:853)
==12304==    by 0xA869AD: if_convertible_gimple_assign_stmt_p
(tree-if-conv.c:98
6)
==12304==    by 0xA869AD: if_convertible_stmt_p (tree-if-conv.c:1026)
==12304==    by 0xA869AD: if_convertible_loop_p_1(loop*, vec<data_reference*,
va
_heap, vl_ptr>*) (tree-if-conv.c:1457)

Also, here is a recent valgrind to show more detail:

$ ../results.258387.valgrind/bin/gcc -c -O3 bug420.c 2>&1 | more
==1913== Invalid read of size 8
==1913==    at 0xA8ECDC: ifcvt_memrefs_wont_trap (tree-if-conv.c:868)
==1913==    by 0xA8ECDC: if_convertible_gimple_assign_stmt_p
(tree-if-conv.c:100
1)
==1913==    by 0xA8ECDC: if_convertible_stmt_p (tree-if-conv.c:1041)
==1913==    by 0xA8ECDC: if_convertible_loop_p_1(loop*, vec<data_reference*,
va_
heap, vl_ptr>*) (tree-if-conv.c:1472)

I'll have my usual go at reducing the code.

Reply via email to