From 121075d7601b521973522cce134567beb0c913bb Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Mon, 20 Nov 2017 20:52:14 +0100 Subject: [PATCH] i386.md (bswaphi2): New expander. * 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 | 28 +++++++++++---------- gcc/config/i386/i386.md | 33 +++++++++++++++++++++++++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.target/i386/movbe-5.c | 18 ++++++++++++++ 4 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/movbe-5.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 05b3e656b87..1499934c6f2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-11-20 Uros Bizjak + + * config/i386/i386.md (bswaphi2): New expander. + (*bswaphi2_movbe): New insn pattern. + (bswaphi -> rorhi pepehole2): New peephole pattern. + 2017-11-20 Jeff Law * Makefile.in (OBJS): Add gimple-ssa-evrp-analyze.o. @@ -161,8 +167,7 @@ 2017-11-19 Jan Hubicka 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 @@ -301,8 +306,7 @@ 2017-11-17 Jan Hubicka - * 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 @@ -466,8 +470,7 @@ * 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 @@ -519,8 +522,8 @@ 2017-11-16 Jan Hubicka - * 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 @@ -2206,9 +2209,8 @@ 2017-11-06 James Bowman - * 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 @@ -3448,7 +3450,7 @@ * doc/tm.texi (TARGET_FLOATN_BUILTIN_P): Likewise. 2017-10-31 Matthew Fortune - Eric Botcazou + Eric Botcazou PR rtl-optimization/81803 * lra-constraints.c (curr_insn_transform): Also reload the whole @@ -3553,7 +3555,7 @@ 2017-10-31 Olivier Hainque - * 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 diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 1e918233ddf..0eaa1f244f3 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -14091,6 +14091,39 @@ (set_attr "modrm" "0") (set_attr "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))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 949eb1946a3..ee6a910958f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-11-20 Uros Bizjak + Jakub Jelinek + + * gcc.target/i386/movbe-5.c: New test. + 2017-11-20 Paul Thomas 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 index 00000000000..72e4165391d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/movbe-5.c @@ -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; +} -- 2.30.2