Changed recently between 20180107 and 20180114. Affects testfile gcc/testsuite/gfortran.dg/pr71230-1.f90 (and others). $ gfortran-8-20180107 -c pr71230-1.f90 -O3 -ftrapv $ gfortran-7-20180125 -c pr71230-1.f90 -O3 -ftrapv $ $ gfortran-8-20180128 -c pr71230-1.f90 -O3 -ftrapv during GIMPLE pass: vect f951: internal compiler error: in gimplify_modify_expr, at gimplify.c:5798 0x97e137 gimplify_modify_expr ../../gcc/gimplify.c:5797 0x974a4b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gimplify.c:11435 0x976d76 gimplify_stmt(tree_node**, gimple**) ../../gcc/gimplify.c:6658 0x97947e gimplify_cond_expr ../../gcc/gimplify.c:4128 0x974a81 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gimplify.c:11391 0x976d76 gimplify_stmt(tree_node**, gimple**) ../../gcc/gimplify.c:6658 0x9791e5 gimplify_cond_expr ../../gcc/gimplify.c:4025 0x974a81 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gimplify.c:11391 0x973b0b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gimplify.c:12160 0x974ecc gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gimplify.c:12098 0x973aec gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gimplify.c:12158 0x973aec gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gimplify.c:12158 0x973aec gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gimplify.c:12158 0x983e71 force_gimple_operand_1(tree_node*, gimple**, bool (*)(tree_node*), tree_node*) ../../gcc/gimplify-me.c:78 0xd9ea3a vect_loop_versioning(_loop_vec_info*, unsigned int, bool, poly_int<1u, unsigned long>) ../../gcc/tree-vect-loop-manip.c:3018 0xd8a83a vect_transform_loop(_loop_vec_info*) ../../gcc/tree-vect-loop.c:8607 0xdaf084 vectorize_loops() ../../gcc/tree-vectorizer.c:740
Hmm, another -ftrapv issue. I don't remember if we fixed the other one that appeared recently yet.
I think we haven't fixed that. I think we just want to transform -ftrapv to ubsan-like trapping internal fns, but it is too late for that for GCC8.
This started to ICE in particular with r256644. The other PR we have about -ftrapv and vectorization is PR81661 (and probably others).
Created attachment 43305 [details] gcc8-pr84117.patch Untested fix. Richard, or do you want to put it into another source file/header?
On Wed, 31 Jan 2018, jakub at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84117 > > Jakub Jelinek <jakub at gcc dot gnu.org> changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > Status|NEW |ASSIGNED > Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org > > --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- > Created attachment 43305 [details] > --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43305&action=edit > gcc8-pr84117.patch > > Untested fix. Richard, or do you want to put it into another source > file/header? The file works for me. Note instead of the switch () you probably want to use if (! operation_no_trapping_overflow (TREE_TYPE (*tp), TREE_CODE (*tp))) return *tp; so we keep a single place to specify which tree codes will end up trapping for which type. Otherwise looks ok but I'd do the rewrite in number_of_iterations_exit instead? Which also means another option would be to say chrec_dont_know there if find_trapping_overflow (). That might be even safer given I'm sure we'll run into similar issues with SCEV ... (but maybe I've fixed enough of the undefined overflow cases there to also catch traps...)
Author: jakub Date: Thu Feb 1 10:08:26 2018 New Revision: 257284 URL: https://gcc.gnu.org/viewcvs?rev=257284&root=gcc&view=rev Log: PR tree-optimization/81661 PR tree-optimization/84117 * tree-eh.h (rewrite_to_non_trapping_overflow): Declare. * tree-eh.c: Include gimplify.h. (find_trapping_overflow, replace_trapping_overflow, rewrite_to_non_trapping_overflow): New functions. * tree-vect-loop.c: Include tree-eh.h. (vect_get_loop_niters): Use rewrite_to_non_trapping_overflow. * tree-data-ref.c: Include tree-eh.h. (get_segment_min_max): Use rewrite_to_non_trapping_overflow. * gcc.dg/pr81661.c: New test. * gfortran.dg/pr84117.f90: New test. Added: trunk/gcc/testsuite/gcc.dg/pr81661.c trunk/gcc/testsuite/gfortran.dg/pr84117.f90 Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-data-ref.c trunk/gcc/tree-eh.c trunk/gcc/tree-eh.h trunk/gcc/tree-vect-loop.c
Fixed.
Author: jakub Date: Sat Mar 3 13:25:27 2018 New Revision: 258183 URL: https://gcc.gnu.org/viewcvs?rev=258183&root=gcc&view=rev Log: Backported from mainline 2018-02-01 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/81661 PR tree-optimization/84117 * tree-eh.h (rewrite_to_non_trapping_overflow): Declare. * tree-eh.c: Include gimplify.h. (find_trapping_overflow, replace_trapping_overflow, rewrite_to_non_trapping_overflow): New functions. * tree-vect-loop.c: Include tree-eh.h. (vect_get_loop_niters): Use rewrite_to_non_trapping_overflow. * gcc.dg/pr81661.c: New test. * gfortran.dg/pr84117.f90: New test. Added: branches/gcc-7-branch/gcc/testsuite/gcc.dg/pr81661.c branches/gcc-7-branch/gcc/testsuite/gfortran.dg/pr84117.f90 Modified: branches/gcc-7-branch/gcc/ChangeLog branches/gcc-7-branch/gcc/testsuite/ChangeLog branches/gcc-7-branch/gcc/tree-eh.c branches/gcc-7-branch/gcc/tree-eh.h branches/gcc-7-branch/gcc/tree-vect-loop.c