summaryrefslogtreecommitdiff
path: root/gcc/config/bfin/bfin.md
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/config/bfin/bfin.md')
-rw-r--r--gcc/config/bfin/bfin.md41
1 files changed, 32 insertions, 9 deletions
diff --git a/gcc/config/bfin/bfin.md b/gcc/config/bfin/bfin.md
index 2b125b5fc63..221e0ceed82 100644
--- a/gcc/config/bfin/bfin.md
+++ b/gcc/config/bfin/bfin.md
@@ -418,12 +418,23 @@
[(set (match_operand:HI 0 "nonimmediate_operand" "=x,da,x,d,mr")
(match_operand:HI 1 "general_operand" "x,xKs7,xKsh,mr,d"))]
"GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
- "@
- %0 = %1;
- %0 = %1 (X);
- %0 = %1 (X);
- %0 = W %1 (X);
- W %0 = %1;"
+{
+ static const char *templates[] = {
+ "%0 = %1;",
+ "%0 = %1 (X);",
+ "%0 = %1 (X);",
+ "%0 = W %1 (X);",
+ "W %0 = %1;",
+ "%h0 = W %1;",
+ "W %0 = %h1;"
+ };
+ int alt = which_alternative;
+ rtx mem = (MEM_P (operands[0]) ? operands[0]
+ : MEM_P (operands[1]) ? operands[1] : NULL_RTX);
+ if (mem && bfin_dsp_memref_p (mem))
+ alt += 2;
+ return templates[alt];
+}
[(set_attr "type" "move,mvi,mvi,mcld,mcst")
(set_attr "length" "2,2,4,*,*")])
@@ -588,22 +599,34 @@
;; Sign and zero extensions
-(define_insn "extendhisi2"
+(define_insn_and_split "extendhisi2"
[(set (match_operand:SI 0 "register_operand" "=d, d")
(sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "d, m")))]
""
"@
%0 = %h1 (X);
%0 = W %h1 (X);"
+ "reload_completed && bfin_dsp_memref_p (operands[1])"
+ [(set (match_dup 2) (match_dup 1))
+ (set (match_dup 0) (sign_extend:SI (match_dup 2)))]
+{
+ operands[2] = gen_lowpart (HImode, operands[0]);
+}
[(set_attr "type" "alu0,mcld")])
-(define_insn "zero_extendhisi2"
+(define_insn_and_split "zero_extendhisi2"
[(set (match_operand:SI 0 "register_operand" "=d, d")
(zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "d, m")))]
""
"@
%0 = %h1 (Z);
- %0 = W%h1 (Z);"
+ %0 = W %h1 (Z);"
+ "reload_completed && bfin_dsp_memref_p (operands[1])"
+ [(set (match_dup 2) (match_dup 1))
+ (set (match_dup 0) (zero_extend:SI (match_dup 2)))]
+{
+ operands[2] = gen_lowpart (HImode, operands[0]);
+}
[(set_attr "type" "alu0,mcld")])
(define_insn "zero_extendbisi2"