mbox series

[0/3] Support Intel APX CCMP

Message ID 20240515082054.3934069-1-hongyu.wang@intel.com
Headers show
Series Support Intel APX CCMP | expand

Message

Hongyu Wang May 15, 2024, 8:20 a.m. UTC
APX CCMP feature[1] implements conditional compare which executes compare
    when EFLAGS matches certain condition.
    
    CCMP introduces default flags value (dfv), when conditional compare does
    not execute, it will directly set the flags according to dfv.
    
    From APX assembler recommendation document, the instruction is like
    
    ccmpeq {dfv=sf,of,cf,zf}  %rax, %r16
    
    For this instruction, it will test EFLAGS regs if it matches conditional
    code EQ, if yes, compare %rax and %r16 like legacy cmp. If no, the
    EFLAGS will be updated according to dfv, which means SF,OF,CF,ZF are
    set. PF will be set according to CF in dfv, and AF will always be
    cleared.
    
    The dfv part can be a combination of sf,of,cf,zf, like {dfv=cf,zf} which
    sets CF and ZF only and clear others, or {dfv=} which clears all EFLAGS.
    
    To enable CCMP, we implemented the target hook TARGET_GEN_CCMP_FIRST and
    TARGET_GEN_CCMP_NEXT to reuse the current ccmp infrastructure. Also we
    extended the cstorem4 optab to support storing different CCmode to fit
    current ccmp infrasturcture.

    We also adjusted the middle-end ccmp strategy to support fp comi + int
    ccmp generation.
    All the changes passed bootstrap & regtest on {aarch64/x86-64}-pc-linux-gnu.
    We also tested spec with sde and passed the runtime test.

    Ok for trunk?

[1].https://www.intel.com/content/www/us/en/developer/articles/technical/advanced-performance-extensions-apx.html

Hongyu Wang (3):
  [APX CCMP] Support APX CCMP
  [APX CCMP] Adjust startegy for selecting ccmp candidates
  [APX CCMP] Support ccmp for float compare

 gcc/ccmp.cc                                |  12 +-
 gcc/config/i386/i386-expand.cc             | 164 +++++++++++++++++++++
 gcc/config/i386/i386-opts.h                |   6 +-
 gcc/config/i386/i386-protos.h              |   5 +
 gcc/config/i386/i386.cc                    |  50 +++++++
 gcc/config/i386/i386.h                     |   1 +
 gcc/config/i386/i386.md                    |  35 ++++-
 gcc/config/i386/i386.opt                   |   3 +
 gcc/testsuite/gcc.target/i386/apx-ccmp-1.c | 104 +++++++++++++
 gcc/testsuite/gcc.target/i386/apx-ccmp-2.c | 104 +++++++++++++
 10 files changed, 479 insertions(+), 5 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/apx-ccmp-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/apx-ccmp-2.c