public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Separate macro-fusible instructions from not for -mbranches-within-32B-boundaries
@ 2020-02-28  8:56 Hongtao Liu
  2020-02-28  8:57 ` Hongtao Liu
  0 siblings, 1 reply; 9+ messages in thread
From: Hongtao Liu @ 2020-02-28  8:56 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

Hi:
    This is subsequent patch for JCC Code Erratum.
    Refer to http://sourceware-org.1504.n7.nabble.com/PATCH-0-5-i386-Optimize-for-Jump-Conditional-Code-Erratum-tt598005.html#none

    According to intel SDM manual, not all compare flag-modifying
instructions are marcro-fusible with subsequent jcc instruction. For
those not, -mbranches-within-32B-boundaries need't align them as
FUSED_JCC_PADDING, only jcc itself need to be aligned. Here are 2
restrictions which separate macro-fusible instruction from not

    Restriction 1:
    If TEST/AND/CMP/ADD/SUB/INC/DEC is one of the following format:

       cmp m, imm
       add m, imm
       sub m, imm
       test m, imm
       and m, imm
       inc m
       dec m

    it is unfusible with any jcc instructions.

    Restriction 2:
    /* Table 3-2. Macro-Fusible Instructions in Haswell Microarchitecture
    ---------------------------------------------------------------------
    |   JCC   | ADD/SUB/CMP | INC/DEC | TEST/AND |
    | ------  | ----------- | ------- | -------- |
    |   Jo    |      N      |    N    |     Y    |
    |   Jno   |      N      |    N    |     Y    |
    |  Jc/Jb  |      Y      |    N    |     Y    |
    | Jae/Jnb |      Y      |    N    |     Y    |
    |  Je/Jz  |      Y      |    Y    |     Y    |
    | Jne/Jnz |      Y      |    Y    |     Y    |
    | Jna/Jbe |      Y      |    N    |     Y    |
    | Ja/Jnbe |      Y      |    N    |     Y    |
    |   Js    |      N      |    N    |     Y    |
    |   Jns   |      N      |    N    |     Y    |
    |  Jp/Jpe |      N      |    N    |     Y    |
    | Jnp/Jpo |      N      |    N    |     Y    |
    | Jl/Jnge |      Y      |    Y    |     Y    |
    | Jge/Jnl |      Y      |    Y    |     Y    |
    | Jle/Jng |      Y      |    Y    |     Y    |
    | Jg/Jnle |      Y      |    Y    |     Y    |


Changelog

            * gas/config/tc-i386.h (i386_tc_frag_data): Add member mf_type.
            (TC_FRAG_INIT): Init mf_type.
            * gas/config/tc-i386.c (enum mf_jcc_kind): New enum.
            (enum mf_cmp_kind): Ditto.
            (maybe_fused_with_jcc_p): Add argument mf_cmp_p to get
            mf_type of corresponding instructons, exclude unfusible
            instructions.
            (add_fused_jcc_padding_frag_p): Likewise.
            (add_branch_padding_frag_p): Likewise.
            (output_insn): Record mf_type for corresponding instructions.
            (i386_macro_fusible_p): New function.
            (i386_next_fusible_jcc_frag): Rename from i386_next_jcc_frag,
            add argument cmp_fragP to return next fusible jcc frag only.
            (i386_classify_machine_dependant_frag): Seperate macro-fusible
            instructions from condition jump.
            * gas/testsuite/gas/i386/align-branch-9.s: New file.
            * gas/testsuite/gas/i386/align-branch-9.d: Ditto.
            * gas/testsuite/gas/i386/x86-64-align-branch-9.s: Ditto.
            * gas/testsuite/gas/i386/x86-64-align-branch-9.d: Ditto.
            * gas/testsuite/gas/i386/i386.exp: Run new tests.

-- 
BR,
Hongtao

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-03-03 14:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-28  8:56 [PATCH] Separate macro-fusible instructions from not for -mbranches-within-32B-boundaries Hongtao Liu
2020-02-28  8:57 ` Hongtao Liu
2020-02-28 11:35   ` Jan Beulich
2020-03-02  3:14     ` Hongtao Liu
2020-03-02  4:05       ` Hongtao Liu
2020-03-02  8:32         ` Jan Beulich
2020-03-03  3:40           ` Hongtao Liu
2020-03-03  8:38             ` Jan Beulich
2020-03-03 14:12               ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).