From 1504f0b4b1d481479c0fc915ae74095b7dd8065d Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 19 Mar 2019 11:05:10 +0100 Subject: [PATCH] re PR target/89506 (ICE: in decompose, at rtl.h:2266 with -Og -g) PR target/89506 * config/arm/arm.md (cmpsi2_addneg): Swap the alternatives and use subs for the first alternative except when operands[3] is 1. From-SVN: r269795 --- gcc/ChangeLog | 4 ++++ gcc/config/arm/arm.md | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f96d515a92e..9327ed858db 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2019-03-19 Jakub Jelinek + PR target/89506 + * config/arm/arm.md (cmpsi2_addneg): Swap the alternatives and use + subs for the first alternative except when operands[3] is 1. + PR target/89752 * gimplify.c (gimplify_asm_expr): For output argument with TREE_ADDRESSABLE type, clear allows_reg if it allows memory, otherwise diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 18059014b8b..0aecd03891c 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -857,27 +857,27 @@ (set_attr "type" "alus_sreg")] ) -;; This is the canonicalization of addsi3_compare0_for_combiner when the +;; This is the canonicalization of subsi3_compare when the ;; addend is a constant. (define_insn "cmpsi2_addneg" [(set (reg:CC CC_REGNUM) (compare:CC (match_operand:SI 1 "s_register_operand" "r,r") - (match_operand:SI 2 "arm_addimm_operand" "L,I"))) + (match_operand:SI 2 "arm_addimm_operand" "I,L"))) (set (match_operand:SI 0 "s_register_operand" "=r,r") (plus:SI (match_dup 1) - (match_operand:SI 3 "arm_addimm_operand" "I,L")))] + (match_operand:SI 3 "arm_addimm_operand" "L,I")))] "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) + /* 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), so that + alternative comes first. Both alternatives can match for any 0x??000000 + where except for 0 and INT_MIN it doesn't matter what we choose, and also + for -1 and 1 with TARGET_THUMB2, in that case prefer instruction with #1 + as it is shorter. */ + if (which_alternative == 0 && operands[3] != const1_rtx) return "subs%?\\t%0, %1, #%n3"; else return "adds%?\\t%0, %1, %3"; -- 2.30.2