diff options
author | pkoning <pkoning@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-11-09 01:13:30 +0000 |
---|---|---|
committer | pkoning <pkoning@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-11-09 01:13:30 +0000 |
commit | 46bedd497ca733ae65b3e585d24456fede88410c (patch) | |
tree | ba93dbdcafde222472a44547ffb5b89ff5d84560 /gcc/config/pdp11 | |
parent | 69f9031736e6813aae002d16d5473c8ca06dd3f4 (diff) | |
download | gcc-46bedd497ca733ae65b3e585d24456fede88410c.tar.gz |
* config/pdp11/pdp11.md (lshrsi3, lshrhi3): Fix wrong code.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@166468 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/pdp11')
-rw-r--r-- | gcc/config/pdp11/pdp11.md | 70 |
1 files changed, 61 insertions, 9 deletions
diff --git a/gcc/config/pdp11/pdp11.md b/gcc/config/pdp11/pdp11.md index 65aadf0a9b2..552eb4931c8 100644 --- a/gcc/config/pdp11/pdp11.md +++ b/gcc/config/pdp11/pdp11.md @@ -849,7 +849,7 @@ [(set_attr "length" "2,4")]) ;; lsr -(define_insn "" +(define_insn "lsrhi1" [(set (match_operand:HI 0 "nonimmediate_operand" "=rR,Q") (lshiftrt:HI (match_operand:HI 1 "general_operand" "0,0") (const_int 1)))] @@ -857,7 +857,7 @@ "clc\;ror %0" [(set_attr "length" "2,4")]) -(define_insn "lshrsi3" +(define_insn "lsrsi1" [(set (match_operand:SI 0 "register_operand" "=r") (lshiftrt:SI (match_operand:SI 1 "general_operand" "0") (const_int 1)))] @@ -880,6 +880,36 @@ } [(set_attr "length" "10")]) +(define_expand "lshrsi3" + [(match_operand:SI 0 "register_operand" "") + (match_operand:SI 1 "register_operand" "0") + (match_operand:HI 2 "general_operand" "")] + "" + " +{ + rtx r; + + if (!TARGET_40_PLUS && + (GET_CODE (operands[2]) != CONST_INT || + (unsigned) INTVAL (operands[2]) > 3)) + FAIL; + emit_insn (gen_lsrsi1 (operands[0], operands[1])); + if (GET_CODE (operands[2]) != CONST_INT) + { + r = gen_reg_rtx (HImode); + emit_insn (gen_subhi3 (r, operands [2], GEN_INT (1))); + emit_insn (gen_ashrsi3 (operands[0], operands[0], r)); + } + else if ((unsigned) INTVAL (operands[2]) != 1) + { + emit_insn (gen_ashlsi3 (operands[0], operands[0], + GEN_INT (1 - INTVAL (operands[2])))); + } + DONE; +} +" +) + ;; shift is by arbitrary count is expensive, ;; shift by one cheap - so let's do that, if ;; space doesn't matter @@ -996,13 +1026,35 @@ operands[2] = negate_rtx (HImode, operands[2]); }") -;;;;- logical shift instructions -;;(define_insn "lshrsi3" -;; [(set (match_operand:HI 0 "register_operand" "=r") -;; (lshiftrt:HI (match_operand:HI 1 "register_operand" "0") -;; (match_operand:HI 2 "general_operand" "rI")))] -;; "" -;; "srl %0,%2") +(define_expand "lshrhi3" + [(match_operand:HI 0 "register_operand" "") + (match_operand:HI 1 "register_operand" "") + (match_operand:HI 2 "general_operand" "")] + "" + " +{ + rtx r; + + if (!TARGET_40_PLUS && + (GET_CODE (operands[2]) != CONST_INT || + (unsigned) INTVAL (operands[2]) > 3)) + FAIL; + emit_insn (gen_lsrhi1 (operands[0], operands[1])); + if (GET_CODE (operands[2]) != CONST_INT) + { + r = gen_reg_rtx (HImode); + emit_insn (gen_subhi3 (r, operands [2], GEN_INT (1))); + emit_insn (gen_ashrhi3 (operands[0], operands[0], r)); + } + else if ((unsigned) INTVAL (operands[2]) != 1) + { + emit_insn (gen_ashlhi3 (operands[0], operands[0], + GEN_INT (1 - INTVAL (operands[2])))); + } + DONE; +} +" +) ;; absolute |