re PR target/78904 (zero-extracts are not effective)
authorUros Bizjak <uros@gcc.gnu.org>
Wed, 28 Dec 2016 15:16:26 +0000 (16:16 +0100)
committerUros Bizjak <uros@gcc.gnu.org>
Wed, 28 Dec 2016 15:16:26 +0000 (16:16 +0100)
PR target/78904
* config/i386/constraints.md (Bn): New special memory constraint.
* config/i386/predicates.md (norex_memory_operand): New predicate.
* config/i386/i386.md (*extzvqi_mem_rex64): New insn pattern and
corresponding peephole2 pattern.

testsuite/ChangeLog:

PR target/78904
* gcc.target/i386/pr78904-4.c: New test.
* gcc.target/i386/pr78904-5.c: Ditto.

From-SVN: r243955

gcc/ChangeLog
gcc/config/i386/constraints.md
gcc/config/i386/i386.md
gcc/config/i386/predicates.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr78904-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr78904-5.c [new file with mode: 0644]

index c8e2c420936f8f34ce8a16c2d1bf802b695d1e4e..580d91877ae6769bb6d37b725858f47d7eb1de16 100644 (file)
@@ -1,3 +1,11 @@
+2016-12-28  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR target/78904
+       * config/i386/constraints.md (Bn): New special memory constraint.
+       * config/i386/predicates.md (norex_memory_operand): New predicate.
+       * config/i386/i386.md (*extzvqi_mem_rex64): New insn pattern and
+       corresponding peephole2 pattern.
+
 2016-12-27  Sandra Loosemore  <sandra@codesourcery.com>
 
        * doc/cppdiropts.texi, doc/cppwarnopts.texi:  New files, split from...
@@ -6,7 +14,7 @@
        * doc/invoke.texi (Option Summary): Add missing preprocesor-related
        options.  Adjust sorting and formatting.
        (Warning Options): Include cppwarnopts.texi.
-       (Preprocessor Options): Add pointers and list the specific 
+       (Preprocessor Options): Add pointers and list the specific
        preprocessor options from cppopts.texi first instead of last.
        (Directory Options): Move/merge documentation of -I, -iquote, and
        -I- to cppdiropts.texi.  Include that file here.
index 6aa2e4f95b78b68dd4bd0aa3227c3f2ba6733927..19edd25c69931d1bd7141ae6011ad6ebc576862e 100644 (file)
 ;;  g  GOT memory operand.
 ;;  m  Vector memory operand
 ;;  c  Constant memory operand
+;;  n  Memory operand without REX prefix
 ;;  s  Sibcall memory operand, not valid for TARGET_X32
 ;;  w  Call memory operand, not valid for TARGET_X32
 ;;  z  Constant call address operand.
   (and (match_operand 0 "memory_operand")
        (match_test "constant_address_p (XEXP (op, 0))")))
 
+(define_special_memory_constraint "Bn"
+  "@internal Memory operand without REX prefix."
+  (match_operand 0 "norex_memory_operand"))
+
 (define_constraint "Bs"
   "@internal Sibcall memory operand."
   (ior (and (not (match_test "TARGET_X32"))
index 13769f987ff743cd54f604a0ad601dff29db24b8..cf9dc03ba8b2640503e7ee28a272c53e96b202d6 100644 (file)
   [(set_attr "type" "imovx")
    (set_attr "mode" "SI")])
 
+(define_insn "*extzvqi_mem_rex64"
+  [(set (match_operand:QI 0 "norex_memory_operand" "=Bn")
+       (subreg:QI
+         (zero_extract:SI (match_operand 1 "ext_register_operand" "Q")
+                          (const_int 8)
+                          (const_int 8)) 0))]
+  "TARGET_64BIT && reload_completed"
+  "mov{b}\t{%h1, %0|%0, %h1}"
+  [(set_attr "type" "imov")
+   (set_attr "mode" "QI")])
+
 (define_insn "*extzvqi"
   [(set (match_operand:QI 0 "nonimmediate_operand" "=QBc,?R,m")
-        (subreg:QI
+       (subreg:QI
          (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q,Q")
                           (const_int 8)
                           (const_int 8)) 0))]
        (const_string "SI")
        (const_string "QI")))])
 
+(define_peephole2
+  [(set (match_operand:QI 0 "register_operand")
+       (subreg:QI
+         (zero_extract:SI (match_operand 1 "ext_register_operand")
+                          (const_int 8)
+                          (const_int 8)) 0))
+   (set (match_operand:QI 2 "norex_memory_operand") (match_dup 0))]
+  "TARGET_64BIT
+   && peep2_reg_dead_p (2, operands[0])"
+  [(set (match_dup 2)
+       (subreg:QI
+         (zero_extract:SI (match_dup 1)
+                          (const_int 8)
+                          (const_int 8)) 0))])
+
 (define_expand "insv<mode>"
   [(set (zero_extract:SWI248 (match_operand:SWI248 0 "register_operand")
                             (match_operand:SI 1 "const_int_operand")
index b2d847e991fbbfaf1acd54797caadc37dbad7c28..a1ea34f4f284d318cbbe4b08fbf2ab67e9195bce 100644 (file)
   (ior (match_operand 0 "register_operand")
        (match_operand 0 "const0_operand")))
 
+(define_predicate "norex_memory_operand"
+  (and (match_operand 0 "memory_operand")
+       (not (match_test "x86_extended_reg_mentioned_p (op)"))))
+
 ;; Return true for RTX codes that force SImode address.
 (define_predicate "SImode_address_operand"
   (match_code "subreg,zero_extend,and"))
index 2f2db1ac9a142f91bbc0e558a408431208e4c308..09b2b5bda7bbad18f50a1f3a4449643a6b0d3240 100644 (file)
@@ -1,3 +1,9 @@
+2016-12-28  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR target/78904
+       * gcc.target/i386/pr78904-4.c: New test.
+       * gcc.target/i386/pr78904-5.c: Ditto.
+
 2016-12-27  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        * gcc.target/powerpc/p9-vinsert4b-2.c: Update test to test for 13
diff --git a/gcc/testsuite/gcc.target/i386/pr78904-4.c b/gcc/testsuite/gcc.target/i386/pr78904-4.c
new file mode 100644 (file)
index 0000000..d110c2e
--- /dev/null
@@ -0,0 +1,21 @@
+/* PR target/78904 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -masm=att" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+struct S1
+{
+  unsigned char pad1;
+  unsigned char val;
+  unsigned short pad2;
+};
+
+extern unsigned char t[256];
+
+void foo (struct S1 a, size_t i)
+{
+  t[i] = a.val;
+}
+
+/* { dg-final { scan-assembler "\[ \t\]movb\[\t \]*%.h," } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr78904-5.c b/gcc/testsuite/gcc.target/i386/pr78904-5.c
new file mode 100644 (file)
index 0000000..5286e67
--- /dev/null
@@ -0,0 +1,27 @@
+/* PR target/78904 */
+/* { dg-do assemble { target { ! ia32 } } } */
+/* { dg-options "-O2" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+struct S1
+{
+  unsigned char pad1;
+  unsigned char val;
+  unsigned short pad2;
+};
+
+extern unsigned char t[256];
+
+void foo (struct S1 a, size_t i)
+{
+  t[i] = a.val;
+}
+
+void bar (struct S1 a, size_t i)
+{
+  register size_t _i __asm ("r10") = i;
+
+  asm volatile ("" : "+r" (_i));
+  t[_i] = a.val;
+}