From 3aa8dfe36031ded18994076d290f1ed3456dc197 Mon Sep 17 00:00:00 2001 From: Oleg Endo Date: Thu, 8 Jan 2015 11:07:45 +0000 Subject: [PATCH] re PR target/55212 ([SH] Switch to LRA) gcc/ PR target/55212 * config/sh/sh.md (*addsi3_compact): Emit reg-reg copy instead of constant load if constant operand fits into I08. From-SVN: r219341 --- gcc/ChangeLog | 6 ++++++ gcc/config/sh/sh.md | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 26615505ec8..2d5fcb383df 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-01-08 Oleg Endo + + PR target/55212 + * config/sh/sh.md (*addsi3_compact): Emit reg-reg copy instead of + constant load if constant operand fits into I08. + 2015-01-08 Jakub Jelinek PR sanitizer/64336 diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md index 6e0b97f2fdd..bbbdc1960e4 100644 --- a/gcc/config/sh/sh.md +++ b/gcc/config/sh/sh.md @@ -2061,8 +2061,9 @@ ;; The problem is that LRA expects something like ;; (set rA (plus rB (const_int N))) ;; to work. We can do that, but we have to split out an additional reg-reg -;; copy before the actual add insn. Use u constraint for that case to avoid -;; the invalid value in the stack pointer. +;; copy or constant load before the actual add insn. +;; Use u constraint for that case to avoid the invalid value in the stack +;; pointer. (define_insn_and_split "*addsi3_compact" [(set (match_operand:SI 0 "arith_reg_dest" "=r,&u") (plus:SI (match_operand:SI 1 "arith_operand" "%0,r") @@ -2078,7 +2079,11 @@ && ! reg_overlap_mentioned_p (operands[0], operands[1])" [(set (match_dup 0) (match_dup 2)) (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))] - "" +{ + /* Prefer 'mov r0,r1; add #imm8,r1' over 'mov #imm8,r1; add r0,r1' */ + if (satisfies_constraint_I08 (operands[2])) + std::swap (operands[1], operands[2]); +} [(set_attr "type" "arith")]) ;; ------------------------------------------------------------------------- -- 2.30.2