[PATCH] PR47440 - Use LCM for vzeroupper insertion

Vladimir Yakovlev vbyakovl23@gmail.com
Tue Aug 21 13:52:00 GMT 2012


Please review changes for vzeroupper placement using mode switching
technique. This fixes
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47440.
Bootstrap and make check was performed. I used compiler

Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --enable-languages=c,c++,fortran
--with-arch=corei7 --with-cpu=corei7 --with-fpmath=sse

There are fails.
FAIL: gcc.target/i386/avx-vzeroupper-3.c execution test
FAIL: gcc.target/x86_64/abi/avx/test_passing_unions.c execution,  -O2
FAIL: gcc.target/x86_64/abi/avx/test_passing_unions.c execution,  -O3
-fomit-frame-pointer
FAIL: gcc.target/x86_64/abi/avx/test_passing_unions.c execution,  -O3
-fomit-frame-pointer -funroll-loops
FAIL: gcc.target/x86_64/abi/avx/test_passing_unions.c execution,  -O3
-fomit-frame-pointer -funroll-all-loops -finline-functions
FAIL: gcc.target/x86_64/abi/avx/test_passing_unions.c execution,  -O3
-g

avx-vzeroupper-3 fails because reload moves AVX store through vzeroupper.

Before reload
(insn 2 27 3 2 (set (reg/v:V4DI 61 [ src ])
        (reg:V4DI 21 xmm0 [ src ]))
/export/users/vbyakovl/workspaces/vzu/gcc/gcc/testsuite/gcc.target/i386/avx-vzeroupper-3.c:22
1093 {*movv4di_internal}
     (expr_list:REG_DEAD (reg:V4DI 21 xmm0 [ src ])
        (nil)))
(note 3 2 6 2 NOTE_INSN_FUNCTION_BEG)
(insn 6 3 29 2 (set (reg:QI 0 ax)
        (const_int 0 [0]))
/export/users/vbyakovl/workspaces/vzu/gcc/gcc/testsuite/gcc.target/i386/avx-vzeroupper-3.c:23
67 {*movqi_internal}
     (nil))
(insn 29 6 7 2 (unspec_volatile [
            (const_int 9 [0x9])
        ] UNSPECV_VZEROUPPER)
/export/users/vbyakovl/workspaces/vzu/gcc/gcc/testsuite/gcc.target/i386/avx-vzeroupper-3.c:23
1840 {avx_vzeroupper}
     (nil))
(call_insn 7 29 9 2 (call (mem:QI (symbol_ref:DI ("foo") [flags 0x3]
<function_decl 0x7f4cf8fe8500 foo>) [0 foo S1 A8])

After reload
(insn 6 3 29 2 (set (reg:QI 0 ax)
        (const_int 0 [0]))
/export/users/vbyakovl/workspaces/vzu/gcc/gcc/testsuite/gcc.target/i386/avx-vzeroupper-3.c:23
67 {*movqi_internal}
     (nil))
(insn 29 6 33 2 (unspec_volatile [
            (const_int 9 [0x9])
        ] UNSPECV_VZEROUPPER)
/export/users/vbyakovl/workspaces/vzu/gcc/gcc/testsuite/gcc.target/i386/avx-vzeroupper-3.c:23
1840 {avx_vzeroupper}
     (nil))
(insn 33 29 7 2 (set (mem/c:V4DI (reg/f:DI 7 sp) [4 S32 A256])
        (reg:V4DI 21 xmm0))
/export/users/vbyakovl/workspaces/vzu/gcc/gcc/testsuite/gcc.target/i386/avx-vzeroupper-3.c:23
1093 {*movv4di_internal}
     (nil))
(call_insn 7 33 9 2 (call (mem:QI (symbol_ref:DI ("foo") [flags 0x3]
<function_decl 0x7f4cf8fe8500 foo>) [0 foo S1 A8])

I think it is data flow analyze problem. Uros  refers to code at
df-scan.c, line 3248 . He wrote

This kind of defeat the purpose of UNSPEC_VOLATILE, and is probably
the root cause of moves.  I don't know how to attack this efficiently,
I suggest to ask on the list about the issue.

What is possible solution in this case?

test_passing_unions. It is a compiler error also. I failed PR54342 on
this issue.

Ok for trunk?

2012-08-25  Vladimir Yakovlev  <vladimir.b.yakovlev@intel.com>

        * config/epiphany/epiphany.h (EMIT_MODE_SET): Added an argument.

        * config/i386/i386-protos.h (emit_i387_cw_initialization):
        Deleted
        (emit_vzero): Added prototype
        (ix86_mode_entry): Likewise
        (ix86_mode_exit): Likewise
        (ix86_emit_mode_set): Likewise.

        * config/i386/i386.c (typedef struct block_info_def): Deleted
        (define BLOCK_INFO): Deleted
        (check_avx256_stores): Added checking for MEM_P
        (move_or_delete_vzeroupper_2): Deleted
        (move_or_delete_vzeroupper_1): Deleted
        (move_or_delete_vzeroupper): Deleted
        (ix86_maybe_emit_epilogue_vzeroupper): Deleted
        (function_pass_avx256_p): Deleted
        (ix86_function_ok_for_sibcall): Deleted disabling sibcall
        (nit_cumulative_args): Deleted initialization of of avx256 fields of
        cfun->machine
        (ix86_emit_restore_sse_regs_using_mov): Deleted vzeroupper generation
        (ix86_expand_epilogue): Likewise
        (is_vzeroupper): New
        (is_vzeroall): Likewise
        (ix86_avx_u128_mode_needed): Likewise
        (x86_mode_needed): Addad a switch case for AVX_U128
        (x86_avx_u128_mode_after): New
        (x86_mode_after): Likewise
        (ix86_avx_u128_mode_entry): Likewise
        (ix86_mode_entry): Likewise
        (x86_avx_u128_mode_exit): Likewise
        (ix86_mode_exit): Likewise
        (x86_emit_vzeroupper): Likewise
        (ix86_emit_mode_set): Likewise
        (x86_expand_call): Deleted vzeroupper generation
        (ix86_split_call_vzeroupper): Deleted
        (x86_init_machine_status): Initialzed optimize_mode_switching
        (ix86_expand_special_args_builtin): Changed
        (ix86_reorg): Deletd a call of move_or_delete_vzeroupper.

        * config/i386/i386.h (AVX_U128): New
        (NUM_MODES_FOR_MODE_SWITCHING): Added AVX_U128_ANY
        (MODE_AFTER): New
        (MODE_ENTRY): Likewise
        (MODE_EXIT): Likewise
        (EMIT_MODE_SET): Changed
        (machine_function): Deleted avx256 fields.

        * config/i386/i386.md (UNSPEC_CALL_NEEDS_VZEROUPPER): Deleted
        (define_insn_and_split "*call_vzeroupper): Likewise.
        (define_insn_and_split "*call_rex64_ms_sysv_vzeroupper"): Likewise
        (define_insn_and_split "*sibcall_vzeroupper"): Likewise
        (define_insn_and_split "*call_pop_vzeroupper"): Likewise
        (define_insn_and_split "*sibcall_pop_vzeroupper"): Likewise
        (define_insn_and_split "*call_value_vzeroupper"): Likewise
        (define_insn_and_split "*sibcall_value_vzeroupper"): Likewise
        (define_insn_and_split "*call_value_rex64_ms_sysv_vzeroupper"): Likewise
        (define_insn_and_split "*call_value_pop_vzeroupper"): Likewise
        (define_insn_and_split "*sibcall_value_pop_vzeroupper"): Likewise
        (define_expand "return"): Delete vzeroupper emitting
        (define_expand "simple_return"): Likewise.

        * config/sh/sh.h (MODE_AFTER): Added an argument
        (EMIT_MODE_SET): Likewise.

        * mode-switching.c (transp): Changed type
        (make_preds_opaque): Added an argument
        (optimize_mode_switching): Added code for VZEROUPPER elemination.

2012-08-20  Vladimir Yakovlev  <vladimir.b.yakovlev@intel.com>

        * gcc.target/i386/avx-vzeroupper-5.c: Changed scan-assembler-times
        gcc.target/i386/avx-vzeroupper-8.c: Likewise
        gcc.target/i386/avx-vzeroupper-9.c: Likewise
        gcc.target/i386/avx-vzeroupper-10.c: Likewise
        gcc.target/i386/avx-vzeroupper-11.c: Likewise
        gcc.target/i386/avx-vzeroupper-12.c: Likewise
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch
Type: application/octet-stream
Size: 52263 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20120821/486a82ba/attachment.obj>


More information about the Gcc-patches mailing list