diff options
author | Jakub Jelinek <jakub@redhat.com> | 2018-03-16 22:01:16 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2018-03-16 22:01:16 +0100 |
commit | 927fb0bc9b915bbe32b4d137adbbcdd3375e119a (patch) | |
tree | 6b3bc9dd4c8e250c0bf6a184d3e767e7be181185 /gcc | |
parent | ce811fc49bb470856f6c4953c071d5b3db6485bb (diff) | |
download | gcc-927fb0bc9b915bbe32b4d137adbbcdd3375e119a.zip gcc-927fb0bc9b915bbe32b4d137adbbcdd3375e119a.tar.gz gcc-927fb0bc9b915bbe32b4d137adbbcdd3375e119a.tar.bz2 |
re PR target/84899 (ICE: in final_scan_insn_1, at final.c:3139 (error: could not split insn))
PR target/84899
* postreload.c (reload_combine_recognize_pattern): Perform
INTVAL addition in unsigned HOST_WIDE_INT type to avoid UB and
truncate_int_for_mode the result for the destination's mode.
* gcc.dg/pr84899.c: New test.
From-SVN: r258610
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/postreload.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr84899.c | 12 |
4 files changed, 29 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7aeedb7..9188921 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2018-03-16 Jakub Jelinek <jakub@redhat.com> + PR target/84899 + * postreload.c (reload_combine_recognize_pattern): Perform + INTVAL addition in unsigned HOST_WIDE_INT type to avoid UB and + truncate_int_for_mode the result for the destination's mode. + PR c/84909 * hsa-gen.c (mem_type_for_type): Fix comment typo. * tree-vect-loop-manip.c (vect_create_cond_for_niters_checks): diff --git a/gcc/postreload.c b/gcc/postreload.c index af9ad82..0638709 100644 --- a/gcc/postreload.c +++ b/gcc/postreload.c @@ -1157,11 +1157,13 @@ reload_combine_recognize_pattern (rtx_insn *insn) value in PREV, the constant loading instruction. */ validate_change (prev, &SET_DEST (prev_set), index_reg, 1); if (reg_state[regno].offset != const0_rtx) - validate_change (prev, - &SET_SRC (prev_set), - GEN_INT (INTVAL (SET_SRC (prev_set)) - + INTVAL (reg_state[regno].offset)), - 1); + { + HOST_WIDE_INT c + = trunc_int_for_mode (UINTVAL (SET_SRC (prev_set)) + + UINTVAL (reg_state[regno].offset), + GET_MODE (index_reg)); + validate_change (prev, &SET_SRC (prev_set), GEN_INT (c), 1); + } /* Now for every use of REG that we have recorded, replace REG with REG_SUM. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 889e110..85b4190 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-16 Jakub Jelinek <jakub@redhat.com> + + PR target/84899 + * gcc.dg/pr84899.c: New test. + 2018-03-16 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/69395 diff --git a/gcc/testsuite/gcc.dg/pr84899.c b/gcc/testsuite/gcc.dg/pr84899.c new file mode 100644 index 0000000..0706fec --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr84899.c @@ -0,0 +1,12 @@ +/* PR target/84899 */ +/* { dg-do compile } */ +/* { dg-options "-O -funroll-all-loops -fno-move-loop-invariants" } */ + +void +foo (int x) +{ + int a = 1 / x, b = 0; + + while ((a + b + 1) < x) + b = __INT_MAX__; +} |