2017-11-21 Uros Bizjak <ubiz...@gmail.com> * config/i386/i386.md (*bswap<mode>2_movbe): Add integer suffix to movbe mnemonic. (*bswaphi2_movbe): Ditto. (bswaphi_lowpart): Merge with *bswaphi_lowpart_1.
testsuite/ChangeLog: 2017-11-21 Uros Bizjak <ubiz...@gmail.com> * gcc.target/i386/movbe-1.c: Update scan string for movbe with integer suffix. * gcc.target/i386/movbe-2.c: Ditto. * gcc.target/i386/movbe-3.c: Ditto. * gcc.target/i386/movbe-4.c: Ditto. * gcc.target/i386/movbe-5.c: Ditto. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Committed to mainline SVN. Uros.
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 0eaa1f244f3..b8715902c35 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -14074,8 +14074,8 @@ && !(MEM_P (operands[0]) && MEM_P (operands[1]))" "@ bswap\t%0 - movbe\t{%1, %0|%0, %1} - movbe\t{%1, %0|%0, %1}" + movbe{<imodesuffix>}\t{%1, %0|%0, %1} + movbe{<imodesuffix>}\t{%1, %0|%0, %1}" [(set_attr "type" "bitmanip,imov,imov") (set_attr "modrm" "0,1,1") (set_attr "prefix_0f" "*,1,1") @@ -14103,8 +14103,8 @@ && !(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}" + movbe{w}\t{%1, %0|%0, %1} + movbe{w}\t{%1, %0|%0, %1}" [(set_attr "type" "imov") (set_attr "modrm" "*,1,1") (set_attr "prefix_0f" "*,1,1") @@ -14124,26 +14124,25 @@ [(parallel [(set (match_dup 0) (rotate:HI (match_dup 0) (const_int 8))) (clobber (reg:CC FLAGS_REG))])]) -(define_insn "*bswaphi_lowpart_1" +(define_insn "bswaphi_lowpart" [(set (strict_low_part (match_operand:HI 0 "register_operand" "+Q,r")) (bswap:HI (match_dup 0))) (clobber (reg:CC FLAGS_REG))] - "TARGET_USE_XCHGB || optimize_function_for_size_p (cfun)" + "" "@ xchg{b}\t{%h0, %b0|%b0, %h0} rol{w}\t{$8, %0|%0, 8}" - [(set_attr "length" "2,4") + [(set (attr "preferred_for_size") + (cond [(eq_attr "alternative" "0") + (symbol_ref "true")] + (symbol_ref "false"))) + (set (attr "preferred_for_speed") + (cond [(eq_attr "alternative" "0") + (symbol_ref "TARGET_USE_XCHGB")] + (symbol_ref "!TARGET_USE_XCHGB"))) + (set_attr "length" "2,4") (set_attr "mode" "QI,HI")]) -(define_insn "bswaphi_lowpart" - [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r")) - (bswap:HI (match_dup 0))) - (clobber (reg:CC FLAGS_REG))] - "" - "rol{w}\t{$8, %0|%0, 8}" - [(set_attr "length" "4") - (set_attr "mode" "HI")]) - (define_expand "paritydi2" [(set (match_operand:DI 0 "register_operand") (parity:DI (match_operand:DI 1 "register_operand")))] diff --git a/gcc/testsuite/gcc.target/i386/movbe-1.c b/gcc/testsuite/gcc.target/i386/movbe-1.c index 391d4ad9814..053095ca691 100644 --- a/gcc/testsuite/gcc.target/i386/movbe-1.c +++ b/gcc/testsuite/gcc.target/i386/movbe-1.c @@ -15,4 +15,4 @@ bar () return __builtin_bswap32 (x); } -/* { dg-final { scan-assembler-times "movbe\[ \t\]" 2 } } */ +/* { dg-final { scan-assembler-times "movbel\[ \t\]" 2 } } */ diff --git a/gcc/testsuite/gcc.target/i386/movbe-2.c b/gcc/testsuite/gcc.target/i386/movbe-2.c index c198609b722..af3b3ca9ae0 100644 --- a/gcc/testsuite/gcc.target/i386/movbe-2.c +++ b/gcc/testsuite/gcc.target/i386/movbe-2.c @@ -15,5 +15,5 @@ bar () return __builtin_bswap64 (x); } -/* { dg-final { scan-assembler-times "movbe\[ \t\]" 4 { target ia32 } } } */ -/* { dg-final { scan-assembler-times "movbe\[ \t\]" 2 { target { ! ia32 } } } } */ +/* { dg-final { scan-assembler-times "movbel\[ \t\]" 4 { target ia32 } } } */ +/* { dg-final { scan-assembler-times "movbeq\[ \t\]" 2 { target { ! ia32 } } } } */ diff --git a/gcc/testsuite/gcc.target/i386/movbe-3.c b/gcc/testsuite/gcc.target/i386/movbe-3.c index 985bc1eb29e..e02a3016ef1 100644 --- a/gcc/testsuite/gcc.target/i386/movbe-3.c +++ b/gcc/testsuite/gcc.target/i386/movbe-3.c @@ -16,4 +16,4 @@ void set (struct S *s, int i) s->i = i; } -/* { dg-final { scan-assembler-times "movbe\[ \t\]" 2 } } */ +/* { dg-final { scan-assembler-times "movbel\[ \t\]" 2 } } */ diff --git a/gcc/testsuite/gcc.target/i386/movbe-4.c b/gcc/testsuite/gcc.target/i386/movbe-4.c index 906709167e1..966bdf52ba0 100644 --- a/gcc/testsuite/gcc.target/i386/movbe-4.c +++ b/gcc/testsuite/gcc.target/i386/movbe-4.c @@ -17,4 +17,4 @@ bar () return __builtin_bswap32 (x); } -/* { dg-final { scan-assembler-times "movbe\[ \t\]" 2 } } */ +/* { dg-final { scan-assembler-times "movbel\[ \t\]" 2 } } */ diff --git a/gcc/testsuite/gcc.target/i386/movbe-5.c b/gcc/testsuite/gcc.target/i386/movbe-5.c index 72e4165391d..b1ab1215268 100644 --- a/gcc/testsuite/gcc.target/i386/movbe-5.c +++ b/gcc/testsuite/gcc.target/i386/movbe-5.c @@ -1,7 +1,6 @@ /* 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) @@ -16,3 +15,5 @@ bar (char *buf, unsigned int data) buf[0] = data >> 8; buf[1] = data; } + +/* { dg-final { scan-assembler-times "movbew\[ \t\]" 2 } } */