This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] more rlwimi (insvsi) patterns for ppc


After talking with a customer about this testcase:

union foo_
{
  struct foo__
  {
    unsigned int x:7;
    unsigned int y:13;
    unsigned int z:12;
  } foo;
  unsigned int xyz;
} foo;
union bar_ {
  struct bar__ {
    unsigned int z:12;
    unsigned int x:7;
    unsigned int y:13;
  } bar;
  unsigned int xyz;
} bar;
struct_field_assign(){    /* 1 */
  bar.bar.x = foo.foo.x;
}
and_mask_or(){            /* 2 */
  bar.xyz = (bar.xyz & 0xFFF01FFF) | (((foo.xyz >> 25) & ~0xFFFFFF80) <<
13);
}
struct_field_and_mask() {  /* 3 */
  bar.bar.x = (foo.xyz >> 25) & ~0xFFFFFF80;
}
and_mask_struct_field() {  /* 4 */
  bar.xyz = (bar.xyz & 0xFFF01FFF) | (foo.foo.x << 13);
}

and why he wasn't getting rlwimi instructions when the compiler could
probably do it, we discovered that in combine we break up zero_extracts
by default. Now, a while back I got rid of one, but more I think
involves more effort than putting a few debug statements in combine and
printing out patterns - which is where this patch comes from.

I think David had issues with the naming of the patterns, so I'm open to
new names. Otherwise, built and regtested on powerpc-eabi. No
regressions.

OK?

-eric

-- 
Eric Christopher <echristo@redhat.com>

2004-06-22  Eric Christopher  <echristo@redhat.com>

	* config/rs6000/rs6000.md (*rlwimi_internal1, *rlwimi_internal2): New
patterns.

Index: rs6000.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.md,v
retrieving revision 1.305
diff -u -p -w -r1.305 rs6000.md
--- rs6000.md	18 May 2004 05:35:30 -0000	1.305
+++ rs6000.md	22 Jun 2004 17:52:10 -0000
@@ -3036,6 +3036,45 @@
 }"
   [(set_attr "type" "insert_word")])
 
+;; combine patterns for rlwimi
+(define_insn "*rlwimi_internal1"
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
+        (ior:SI (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
+                        (match_operand:SI 1 "mask_operand" "i"))
+                (and:SI (lshiftrt:SI (match_operand:SI 3
"gpc_reg_operand" "r")
+                                     (match_operand:SI 2
"const_int_operand" "i"))
+                        (match_operand:SI 5 "mask_operand" "i"))))]
+  "TARGET_POWERPC && INTVAL(operands[1]) == ~INTVAL(operands[5])"
+  "*
+{
+ int me = extract_ME(operands[5]);
+ int mb = extract_MB(operands[5]);
+ operands[4] = GEN_INT(32 - INTVAL(operands[2]));
+ operands[2] = GEN_INT(mb);
+ operands[1] = GEN_INT(me);
+ return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
+}"
+  [(set_attr "type" "insert_word")])
+
+(define_insn "*rlwimi_internal2"
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
+        (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 3
"gpc_reg_operand" "r")
+                                     (match_operand:SI 2
"const_int_operand" "i"))
+                        (match_operand:SI 5 "mask_operand" "i"))
+                (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
+                        (match_operand:SI 1 "mask_operand" "i"))))]
+  "TARGET_POWERPC && INTVAL(operands[1]) == ~INTVAL(operands[5])"
+  "*
+{
+ int me = extract_ME(operands[5]);
+ int mb = extract_MB(operands[5]);
+ operands[4] = GEN_INT(32 - INTVAL(operands[2]));
+ operands[2] = GEN_INT(mb);
+ operands[1] = GEN_INT(me);
+ return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
+}"
+  [(set_attr "type" "insert_word")])
+
 (define_insn "insvdi"
   [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
 			 (match_operand:SI 1 "const_int_operand" "i")



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]