public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, PR63742][ARM] Fix arm *movhi_insn_arch4 pattern for big-endian
@ 2014-11-05  7:12 Yangfei (Felix)
  2014-11-05 11:01 ` Ramana Radhakrishnan
  0 siblings, 1 reply; 17+ messages in thread
From: Yangfei (Felix) @ 2014-11-05  7:12 UTC (permalink / raw)
  To: gcc-patches, nickc, paul, ramana.radhakrishnan, richard.earnshaw

[-- Attachment #1: Type: text/plain, Size: 3758 bytes --]

Hi,

    This patch fixes PR63742 by improving arm *movhi_insn_arch4 pattern to make it works under big-endian. 
    The idea is simple: Use movw for certain const source operand instead of ldrh.  And exclude the const values which cannot be handled by mov/mvn/movw. 
    I am doing regression test for this patch.  Assuming no issue pops up, OK for trunk? 


Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog	(revision 216838)
+++ gcc/ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2014-11-05  Felix Yang  <felix.yang@huawei.com>
+	Shanyao Chen  <chenshanyao@huawei.com>
+
+	PR target/63742
+	* config/arm/predicates.md (arm_hi_operand): New predicate.
+	(arm_movw_immediate_operand): Similarly.
+	* config/arm/arm.md (*movhi_insn_arch4): Use arm_hi_operand instead of
+	general_operand and add "movw" to the output template.
+
 2014-10-29  Richard Sandiford  <richard.sandiford@arm.com>
 
 	* addresses.h, alias.c, asan.c, auto-inc-dec.c, bt-load.c, builtins.c,
Index: gcc/config/arm/predicates.md
===================================================================
--- gcc/config/arm/predicates.md	(revision 216838)
+++ gcc/config/arm/predicates.md	(working copy)
@@ -144,6 +144,12 @@
   (and (match_code "const_int")
        (match_test "INTVAL (op) == 0")))
 
+(define_predicate "arm_movw_immediate_operand"
+  (and (match_test "TARGET_32BIT && arm_arch_thumb2")
+       (ior (match_code "high")
+            (and (match_code "const_int")
+                 (match_test "(INTVAL (op) & 0xffff0000) == 0")))))
+
 ;; Something valid on the RHS of an ARM data-processing instruction
 (define_predicate "arm_rhs_operand"
   (ior (match_operand 0 "s_register_operand")
@@ -211,6 +217,11 @@
   (ior (match_operand 0 "arm_rhs_operand")
        (match_operand 0 "arm_not_immediate_operand")))
 
+(define_predicate "arm_hi_operand"
+  (ior (match_operand 0 "arm_rhsm_operand")
+       (ior (match_operand 0 "arm_not_immediate_operand")
+            (match_operand 0 "arm_movw_immediate_operand"))))
+
 (define_predicate "arm_di_operand"
   (ior (match_operand 0 "s_register_operand")
        (match_operand 0 "arm_immediate_di_operand")))
Index: gcc/config/arm/arm.md
===================================================================
--- gcc/config/arm/arm.md	(revision 216838)
+++ gcc/config/arm/arm.md	(working copy)
@@ -6285,8 +6285,8 @@
 
 ;; Pattern to recognize insn generated default case above
 (define_insn "*movhi_insn_arch4"
-  [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r")
-	(match_operand:HI 1 "general_operand"      "rIk,K,r,mi"))]
+  [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m,r")
+	(match_operand:HI 1 "arm_hi_operand" "rIk,K,j,r,mi"))]
   "TARGET_ARM
    && arm_arch4
    && (register_operand (operands[0], HImode)
@@ -6294,16 +6294,18 @@
   "@
    mov%?\\t%0, %1\\t%@ movhi
    mvn%?\\t%0, #%B1\\t%@ movhi
+   movw%?\\t%0, %1\\t%@ movhi
    str%(h%)\\t%1, %0\\t%@ movhi
    ldr%(h%)\\t%0, %1\\t%@ movhi"
   [(set_attr "predicable" "yes")
-   (set_attr "pool_range" "*,*,*,256")
-   (set_attr "neg_pool_range" "*,*,*,244")
+   (set_attr "pool_range" "*,*,*,*,256")
+   (set_attr "neg_pool_range" "*,*,*,*,244")
    (set_attr_alternative "type"
                          [(if_then_else (match_operand 1 "const_int_operand" "")
                                         (const_string "mov_imm" )
                                         (const_string "mov_reg"))
                           (const_string "mvn_imm")
+                          (const_string "mov_imm")
                           (const_string "store1")
                           (const_string "load1")])]
 )

[-- Attachment #2: movhi_insn_arch4-fix-v1.patch --]
[-- Type: application/octet-stream, Size: 3309 bytes --]

Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog	(revision 216838)
+++ gcc/ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2014-11-05  Felix Yang  <felix.yang@huawei.com>
+	Shanyao Chen  <chenshanyao@huawei.com>
+
+	PR target/63742
+	* config/arm/predicates.md (arm_hi_operand): New predicate.
+	(arm_movw_immediate_operand): Similarly.
+	* config/arm/arm.md (*movhi_insn_arch4): Use arm_hi_operand instead of
+	general_operand and add "movw" to the output template.
+
 2014-10-29  Richard Sandiford  <richard.sandiford@arm.com>
 
 	* addresses.h, alias.c, asan.c, auto-inc-dec.c, bt-load.c, builtins.c,
Index: gcc/config/arm/predicates.md
===================================================================
--- gcc/config/arm/predicates.md	(revision 216838)
+++ gcc/config/arm/predicates.md	(working copy)
@@ -144,6 +144,12 @@
   (and (match_code "const_int")
        (match_test "INTVAL (op) == 0")))
 
+(define_predicate "arm_movw_immediate_operand"
+  (and (match_test "TARGET_32BIT && arm_arch_thumb2")
+       (ior (match_code "high")
+            (and (match_code "const_int")
+                 (match_test "(INTVAL (op) & 0xffff0000) == 0")))))
+
 ;; Something valid on the RHS of an ARM data-processing instruction
 (define_predicate "arm_rhs_operand"
   (ior (match_operand 0 "s_register_operand")
@@ -211,6 +217,11 @@
   (ior (match_operand 0 "arm_rhs_operand")
        (match_operand 0 "arm_not_immediate_operand")))
 
+(define_predicate "arm_hi_operand"
+  (ior (match_operand 0 "arm_rhsm_operand")
+       (ior (match_operand 0 "arm_not_immediate_operand")
+            (match_operand 0 "arm_movw_immediate_operand"))))
+
 (define_predicate "arm_di_operand"
   (ior (match_operand 0 "s_register_operand")
        (match_operand 0 "arm_immediate_di_operand")))
Index: gcc/config/arm/arm.md
===================================================================
--- gcc/config/arm/arm.md	(revision 216838)
+++ gcc/config/arm/arm.md	(working copy)
@@ -6285,8 +6285,8 @@
 
 ;; Pattern to recognize insn generated default case above
 (define_insn "*movhi_insn_arch4"
-  [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r")
-	(match_operand:HI 1 "general_operand"      "rIk,K,r,mi"))]
+  [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m,r")
+	(match_operand:HI 1 "arm_hi_operand" "rIk,K,j,r,mi"))]
   "TARGET_ARM
    && arm_arch4
    && (register_operand (operands[0], HImode)
@@ -6294,16 +6294,18 @@
   "@
    mov%?\\t%0, %1\\t%@ movhi
    mvn%?\\t%0, #%B1\\t%@ movhi
+   movw%?\\t%0, %1\\t%@ movhi
    str%(h%)\\t%1, %0\\t%@ movhi
    ldr%(h%)\\t%0, %1\\t%@ movhi"
   [(set_attr "predicable" "yes")
-   (set_attr "pool_range" "*,*,*,256")
-   (set_attr "neg_pool_range" "*,*,*,244")
+   (set_attr "pool_range" "*,*,*,*,256")
+   (set_attr "neg_pool_range" "*,*,*,*,244")
    (set_attr_alternative "type"
                          [(if_then_else (match_operand 1 "const_int_operand" "")
                                         (const_string "mov_imm" )
                                         (const_string "mov_reg"))
                           (const_string "mvn_imm")
+                          (const_string "mov_imm")
                           (const_string "store1")
                           (const_string "load1")])]
 )

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2014-12-02 12:22 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-05  7:12 [PATCH, PR63742][ARM] Fix arm *movhi_insn_arch4 pattern for big-endian Yangfei (Felix)
2014-11-05 11:01 ` Ramana Radhakrishnan
2014-11-06  8:36   ` Yangfei (Felix)
2014-11-18  8:54     ` Ramana Radhakrishnan
2014-11-18 11:36       ` Yangfei (Felix)
2014-11-18 12:04         ` Ramana Radhakrishnan
2014-11-18 12:47           ` Yangfei (Felix)
2014-11-18 12:56             ` Ramana Radhakrishnan
2014-11-19  9:42               ` Yangfei (Felix)
2014-11-19 10:26                 ` Ramana Radhakrishnan
2014-11-20  9:24                 ` Ramana Radhakrishnan
2014-11-20  9:25                   ` Yangfei (Felix)
2014-11-20  9:48                   ` Yangfei (Felix)
2014-11-29 10:58                     ` [PATCH PR59593] [arm] Backport r217772 & r217826 to 4.8 & 4.9 Chen Shanyao
2014-11-29 12:11                       ` Yangfei (Felix)
2014-12-02 12:22                       ` Ramana Radhakrishnan
2014-11-12 10:28   ` [PING][PATCH, PR63742][ARM] Fix arm *movhi_insn_arch4 pattern for big-endian Yangfei (Felix)

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).