i386.md (bswaphi2): New expander.
authorUros Bizjak <uros@gcc.gnu.org>
Mon, 20 Nov 2017 19:52:14 +0000 (20:52 +0100)
committerUros Bizjak <uros@gcc.gnu.org>
Mon, 20 Nov 2017 19:52:14 +0000 (20:52 +0100)
* config/i386/i386.md (bswaphi2): New expander.
(*bswaphi2_movbe): New insn pattern.
(bswaphi -> rorhi pepehole2): New peephole pattern.

testsuite/ChangeLog:

* gcc.target/i386/movbe-5.c: New test.

From-SVN: r254967

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

index 05b3e656b87c5cdab425e08642cff71afdf42a2e..1499934c6f2528f86c4d82d3637c2e5b2c355685 100644 (file)
@@ -1,3 +1,9 @@
+2017-11-20  Uros Bizjak  <ubizjak@gmail.com>
+
+       * config/i386/i386.md (bswaphi2): New expander.
+       (*bswaphi2_movbe): New insn pattern.
+       (bswaphi -> rorhi pepehole2): New peephole pattern.
+
 2017-11-20  Jeff Law  <law@redhat.com>
 
        * Makefile.in (OBJS): Add gimple-ssa-evrp-analyze.o.
 2017-11-19  Jan Hubicka  <hubicka@ucw.cz>
 
        PR target/82713
-       * i386.c (ix86_builtin_vectorization_cost): Be ready for insane
-       types.
+       * i386.c (ix86_builtin_vectorization_cost): Be ready for insane types.
 
 2017-11-19  Tom de Vries  <tom@codesourcery.com>
 
 
 2017-11-17  Jan Hubicka  <hubicka@ucw.cz>
 
-       * ipa-cp.c (update_profiling_info): Handle conversion to local
-       profile.
+       * ipa-cp.c (update_profiling_info): Handle conversion to local profile.
        * tree-cfg.c (execute_fixup_cfg): Do fixup same way as inliner does.
 
 2017-11-17  Jeff Law  <law@redhat.com>
 
        * doc/invoke.texi (-std=c17): Refer to 2018 expected publication
        date of C17.
-       (-std=c18, -std=iso9899:2018, -std=gnu18): Document option
-       aliases.
+       (-std=c18, -std=iso9899:2018, -std=gnu18): Document option aliases.
 
 2017-11-16  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
 
 2017-11-16  Jan Hubicka  <hubicka@ucw.cz>
 
-       * predict.c (combine_predictions_for_bb): Preserve zero predicted       
-       eges.
+       * predict.c (combine_predictions_for_bb): Preserve zero predicted
+       edges.
        (expensive_function_p): Remove useless assert.
        (determine_unlikely_bbs): Propagate also forward; determine cold blocks
 
 
 2017-11-06  James Bowman  <james.bowman@ftdichip.com>
 
-       * gcc/dwarf2out.c (modified_type_die): Retain ADDR_SPACE
-       qualifiers.
-        (add_type_attribute) likewise.
+       * gcc/dwarf2out.c (modified_type_die): Retain ADDR_SPACE qualifiers.
+       (add_type_attribute) likewise.
 
 2017-11-06  H.J. Lu  <hongjiu.lu@intel.com>
 
        * doc/tm.texi (TARGET_FLOATN_BUILTIN_P): Likewise.
 
 2017-10-31  Matthew Fortune  <matthew.fortune@imgtec.com>
-            Eric Botcazou  <ebotcazou@adacore.com>
+           Eric Botcazou  <ebotcazou@adacore.com>
 
        PR rtl-optimization/81803
        * lra-constraints.c (curr_insn_transform): Also reload the whole
 
 2017-10-31  Olivier Hainque  <hainque@adacore.com>
 
-        * gcc/Makefile.in (FLAGS_TO_PASS): Pass libsubdir as well.
+       * gcc/Makefile.in (FLAGS_TO_PASS): Pass libsubdir as well.
 
 2017-10-31  Julia Koval  <julia.koval@intel.com>
 
index 1e918233ddf744c48860e93e40ad512874b40161..0eaa1f244f31f5ef17210f829074c0b6aaeacfdb 100644 (file)
    (set_attr "modrm" "0")
    (set_attr "mode" "<MODE>")])
 
+(define_expand "bswaphi2"
+  [(set (match_operand:HI 0 "register_operand")
+       (bswap:HI (match_operand:HI 1 "nonimmediate_operand")))]
+  "TARGET_MOVBE")
+
+(define_insn "*bswaphi2_movbe"
+  [(set (match_operand:HI 0 "nonimmediate_operand" "=Q,r,m")
+       (bswap:HI (match_operand:HI 1 "nonimmediate_operand" "0,m,r")))]
+  "TARGET_MOVBE
+   && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
+  "@
+    xchg{b}\t{%h0, %b0|%b0, %h0}
+    movbe\t{%1, %0|%0, %1}
+    movbe\t{%1, %0|%0, %1}"
+  [(set_attr "type" "imov")
+   (set_attr "modrm" "*,1,1")
+   (set_attr "prefix_0f" "*,1,1")
+   (set_attr "prefix_extra" "*,1,1")
+   (set_attr "pent_pair" "np,*,*")
+   (set_attr "athlon_decode" "vector,*,*")
+   (set_attr "amdfam10_decode" "double,*,*")
+   (set_attr "bdver1_decode" "double,*,*")
+   (set_attr "mode" "QI,HI,HI")])
+
+(define_peephole2
+  [(set (match_operand:HI 0 "general_reg_operand")
+       (bswap:HI (match_dup 0)))]
+  "TARGET_MOVBE
+   && !(TARGET_USE_XCHGB || optimize_function_for_size_p (cfun))
+   && peep2_regno_dead_p (0, FLAGS_REG)"
+  [(parallel [(set (match_dup 0) (rotate:HI (match_dup 0) (const_int 8)))
+             (clobber (reg:CC FLAGS_REG))])])
+
 (define_insn "*bswaphi_lowpart_1"
   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+Q,r"))
        (bswap:HI (match_dup 0)))
index 949eb1946a3c5d8efaa5b70fb082a9a809b132a0..ee6a910958f8171e41ba075d6a5ce664e935577a 100644 (file)
@@ -1,3 +1,8 @@
+2017-11-20  Uros Bizjak  <ubizjak@gmail.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.target/i386/movbe-5.c: New test.
+
 2017-11-20  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/79072
diff --git a/gcc/testsuite/gcc.target/i386/movbe-5.c b/gcc/testsuite/gcc.target/i386/movbe-5.c
new file mode 100644 (file)
index 0000000..72e4165
--- /dev/null
@@ -0,0 +1,18 @@
+/* PR tree-optimization/78821 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -mmovbe" } */
+/* { dg-final { scan-assembler-times "movbe\[ \t\]" 2 } } */
+
+unsigned short
+foo (unsigned short *buf)
+{
+  unsigned short a = buf[0];
+  return ((unsigned short) (a >> 8)) | (unsigned short) (a << 8);
+}
+
+void
+bar (char *buf, unsigned int data)
+{
+  buf[0] = data >> 8;
+  buf[1] = data;
+}