gcc/gcc9-pr89506.patch
Jakub Jelinek 8ccdd26200 9.0.1-0.8
2019-02-27 15:29:11 +01:00

72 lines
2.5 KiB
Diff

2019-02-26 Jakub Jelinek <jakub@redhat.com>
PR target/89506
* config/arm/arm.md (cmpsi2_addneg): Use
trunc_int_for_mode (-INTVAL (...), SImode) instead of -INTVAL (...).
(*subsi3_carryin_compare_const): Similarly, just instead of -UINTVAL.
(*compare_scc splitter): Use gen_int_mode.
(*negscc): Likewise.
* gcc.dg/pr89506.c: New test.
--- gcc/config/arm/arm.md.jj 2019-02-25 11:32:02.914684615 +0100
+++ gcc/config/arm/arm.md 2019-02-26 14:41:41.128767480 +0100
@@ -867,7 +867,9 @@ (define_insn "cmpsi2_addneg"
(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])"
+ "TARGET_32BIT
+ && (INTVAL (operands[2])
+ == trunc_int_for_mode (-INTVAL (operands[3]), SImode))"
"@
adds%?\\t%0, %1, %3
subs%?\\t%0, %1, #%n3"
@@ -1185,7 +1187,9 @@ (define_insn "*subsi3_carryin_compare_co
(minus:SI (plus:SI (match_dup 1)
(match_operand:SI 3 "arm_neg_immediate_operand" "L"))
(ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
- "TARGET_32BIT && UINTVAL (operands[2]) == -UINTVAL (operands[3])"
+ "TARGET_32BIT
+ && (INTVAL (operands[2])
+ == trunc_int_for_mode (-INTVAL (operands[3]), SImode))"
"sbcs\\t%0, %1, #%n3"
[(set_attr "conds" "set")
(set_attr "type" "adcs_imm")]
@@ -9281,7 +9285,7 @@ (define_split
(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
@@ -10061,7 +10065,8 @@ (define_insn_and_split "*negscc"
/* 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]));
--- gcc/testsuite/gcc.dg/pr89506.c.jj 2019-02-26 14:45:29.662027068 +0100
+++ gcc/testsuite/gcc.dg/pr89506.c 2019-02-26 14:45:06.570405009 +0100
@@ -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;
+}