This patch allows constant propagation from HIQI modes, as illustrated
by the attached testcase, by converting them into a new SImode pseudo.
It also merge the HIQI mode patterns using general_movdst_operand for both.
No regression on sh-none-elf. OK for trunk ?
Thanks,
2014-04-22 Christian Bruel
* config/sh/sh.md (mov): Replace movQIHI.
Force immediates to SImode.
2014-04-22 Christian Bruel
* gcc.target/sh/hiconst.c: New test.
Index: gcc/config/sh/sh.md
===
--- gcc/config/sh/sh.md (revision 209556)
+++ gcc/config/sh/sh.md (working copy)
@@ -6978,20 +6978,20 @@ label:
[(set_attr "type" "sfunc")
(set_attr "needs_delay_slot" "yes")])
-(define_expand "movhi"
- [(set (match_operand:HI 0 "general_movdst_operand" "")
- (match_operand:HI 1 "general_movsrc_operand" ""))]
+(define_expand "mov"
+ [(set (match_operand:QIHI 0 "general_movdst_operand")
+ (match_operand:QIHI 1 "general_movsrc_operand"))]
""
{
- prepare_move_operands (operands, HImode);
-})
+ if (can_create_pseudo_p () && CONST_INT_P (operands[1])
+&& REG_P (operands[0]) && REGNO (operands[0]) != R0_REG)
+{
+rtx reg = gen_reg_rtx(SImode);
+emit_move_insn (reg, operands[1]);
+operands[1] = gen_lowpart (mode, reg);
+}
-(define_expand "movqi"
- [(set (match_operand:QI 0 "general_operand" "")
- (match_operand:QI 1 "general_operand" ""))]
- ""
-{
- prepare_move_operands (operands, QImode);
+ prepare_move_operands (operands, mode);
})
;; Specifying the displacement addressing load / store patterns separately
Index: gcc/testsuite/gcc.target/sh/hiconst.c
===
--- gcc/testsuite/gcc.target/sh/hiconst.c (revision 0)
+++ gcc/testsuite/gcc.target/sh/hiconst.c (working copy)
@@ -0,0 +1,22 @@
+/* { dg-do compile { target "sh*-*-*" } } */
+/* { dg-options "-O1" } */
+
+char a;
+int b;
+
+foo(char *pt, int *pti)
+{
+ a = 0;
+ b = 0;
+ *pt = 0;
+ *pti = 0;
+}
+
+rab(char *pt, int *pti)
+{
+ pt[2] = 0;
+ pti[3] = 0;
+}
+
+/* { dg-final { scan-assembler-times "mov\t#0" 2 } } */
+