diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-03-02 09:05:10 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-03-02 09:05:10 +0100 |
commit | 73ba6c712005892fbddb3e4dd7160d218e1b8c50 (patch) | |
tree | 23f55f2090bbf8f16d7a9866aed7bd3445092c07 /gcc | |
parent | 64ef1e96ff72cbf856d1fc8c2eb6e78afd94d86a (diff) | |
download | gcc-73ba6c712005892fbddb3e4dd7160d218e1b8c50.zip gcc-73ba6c712005892fbddb3e4dd7160d218e1b8c50.tar.gz gcc-73ba6c712005892fbddb3e4dd7160d218e1b8c50.tar.bz2 |
re PR target/89506 (ICE: in decompose, at rtl.h:2266 with -Og -g)
PR target/89506
* config/arm/arm.md (cmpsi2_addneg): Use
trunc_int_for_mode (-INTVAL (...), SImode) instead of -INTVAL (...).
If operands[2] is 0 or INT_MIN, force use of subs.
(*compare_scc splitter): Use gen_int_mode.
(*negscc): Likewise.
* config/arm/thumb2.md (*thumb2_negscc): Likewise.
* gcc.dg/pr89506.c: New test.
From-SVN: r269339
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/config/arm/arm.md | 24 | ||||
-rw-r--r-- | gcc/config/arm/thumb2.md | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr89506.c | 14 |
5 files changed, 49 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 96693d3..e9b681f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2019-03-02 Jakub Jelinek <jakub@redhat.com> + + PR target/89506 + * config/arm/arm.md (cmpsi2_addneg): Use + trunc_int_for_mode (-INTVAL (...), SImode) instead of -INTVAL (...). + If operands[2] is 0 or INT_MIN, force use of subs. + (*compare_scc splitter): Use gen_int_mode. + (*negscc): Likewise. + * config/arm/thumb2.md (*thumb2_negscc): Likewise. + 2019-03-01 Kito Cheng <kito.cheng@gmail.com> Monk Chiang <sh.chiang04@gmail.com> diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 8668937..7ee83a5 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -867,10 +867,21 @@ (set (match_operand:SI 0 "s_register_operand" "=r,r") (plus:SI (match_dup 1) (match_operand:SI 3 "arm_addimm_operand" "I,L")))] - "TARGET_32BIT && INTVAL (operands[2]) == -INTVAL (operands[3])" - "@ - adds%?\\t%0, %1, %3 - subs%?\\t%0, %1, #%n3" + "TARGET_32BIT + && (INTVAL (operands[2]) + == trunc_int_for_mode (-INTVAL (operands[3]), SImode))" +{ + /* For 0 and INT_MIN it is essential that we use subs, as adds + will result in different condition codes (like cmn rather than + like cmp). For other immediates, we should choose whatever + will have smaller encoding. */ + if (operands[2] == const0_rtx + || INTVAL (operands[2]) == -HOST_WIDE_INT_C (0x80000000) + || which_alternative == 1) + return "subs%?\\t%0, %1, #%n3"; + else + return "adds%?\\t%0, %1, %3"; +} [(set_attr "conds" "set") (set_attr "type" "alus_sreg")] ) @@ -9302,7 +9313,7 @@ (cond_exec (ne:CC (reg:CC CC_REGNUM) (const_int 0)) (set (match_dup 0) (const_int 1)))] { - operands[3] = GEN_INT (-INTVAL (operands[2])); + operands[3] = gen_int_mode (-INTVAL (operands[2]), SImode); }) (define_split @@ -10082,7 +10093,8 @@ /* Emit subs\\t%0, %1, %2\;mvnne\\t%0, #0 */ if (CONST_INT_P (operands[2])) emit_insn (gen_cmpsi2_addneg (operands[0], operands[1], operands[2], - GEN_INT (- INTVAL (operands[2])))); + gen_int_mode (-INTVAL (operands[2]), + SImode))); else emit_insn (gen_subsi3_compare (operands[0], operands[1], operands[2])); diff --git a/gcc/config/arm/thumb2.md b/gcc/config/arm/thumb2.md index 1116924..b283a7b 100644 --- a/gcc/config/arm/thumb2.md +++ b/gcc/config/arm/thumb2.md @@ -913,7 +913,8 @@ /* Emit subs\\t%0, %1, %2\;it\\tne\;mvnne\\t%0, #0 */ if (CONST_INT_P (operands[2])) emit_insn (gen_cmpsi2_addneg (operands[0], operands[1], operands[2], - GEN_INT (- INTVAL (operands[2])))); + gen_int_mode (-INTVAL (operands[2]), + SImode))); else emit_insn (gen_subsi3_compare (operands[0], operands[1], operands[2])); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 53da7a9..8701bc1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-03-02 Jakub Jelinek <jakub@redhat.com> + + PR target/89506 + * gcc.dg/pr89506.c: New test. + 2019-03-01 Kito Cheng <kito.cheng@gmail.com> Monk Chiang <sh.chiang04@gmail.com> diff --git a/gcc/testsuite/gcc.dg/pr89506.c b/gcc/testsuite/gcc.dg/pr89506.c new file mode 100644 index 0000000..2ec4f32 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr89506.c @@ -0,0 +1,14 @@ +/* PR target/89506 */ +/* { dg-do compile } */ +/* { dg-options "-Og -g -w" } */ + +long long a; +int c; + +int +foo (long long d, short e) +{ + __builtin_sub_overflow (0xffffffff, c, &a); + e >>= ~2147483647 != (int) a; + return d + e; +} |