* [PATCH, SH] Extend HIQI mode constants
@ 2014-04-22 14:45 Christian Bruel
2014-04-23 7:17 ` Kaz Kojima
0 siblings, 1 reply; 2+ messages in thread
From: Christian Bruel @ 2014-04-22 14:45 UTC (permalink / raw)
To: Kaz Kojima, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 275 bytes --]
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,
[-- Attachment #2: hiconst.patch --]
[-- Type: text/x-patch, Size: 1956 bytes --]
2014-04-22 Christian Bruel <christian.bruel@st.com>
* config/sh/sh.md (mov<mode>): Replace movQIHI.
Force immediates to SImode.
2014-04-22 Christian Bruel <christian.bruel@st.com>
* 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<mode>"
+ [(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>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>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 } } */
+
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH, SH] Extend HIQI mode constants
2014-04-22 14:45 [PATCH, SH] Extend HIQI mode constants Christian Bruel
@ 2014-04-23 7:17 ` Kaz Kojima
0 siblings, 0 replies; 2+ messages in thread
From: Kaz Kojima @ 2014-04-23 7:17 UTC (permalink / raw)
To: christian.bruel; +Cc: gcc-patches
Christian Bruel <christian.bruel@st.com> wrote:
> 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 ?
OK.
Regards,
kaz
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-04-23 5:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-22 14:45 [PATCH, SH] Extend HIQI mode constants Christian Bruel
2014-04-23 7:17 ` Kaz Kojima
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).