Skip to content

_mm256_shuffle_ps(_,_,0x44) compiles to vunpcklpd with -march= icelake-client #43458

@llvmbot

Description

@llvmbot
Bugzilla Link 44113
Version 9.0
OS All
Reporter LLVM Bugzilla Contributor
CC @topperc,@DougGregor,@RKSimon,@zygoloid,@rotateright

Extended Description

In a recent Stackoverflow discussion (link: https://stackoverflow.com/questions/58954801/avx-equivalent-for-mm-movelh-ps) we found out that the instruction mm256_shuffle_ps(,_,0x44) is compiled to vunpcklpd by Clang. This is a possible optimization for Skylake and other processors which have identical throughput for shuffles and unpacks.
But as the Stackoverflow-user Peter Cordes mentioned in his answer, Ice Lake processors have a higher throughput for shuffles than for unpacks:

unpack:
https://www.uops.info/table.html?search=vunpcklp&cb_lat=on&cb_tp=on&cb_uops=on&cb_ports=on&cb_SKL=on&cb_ICL=on&cb_measurements=on&cb_iaca30=on&cb_doc=on&cb_avx=on&cb_avx2=on

shuffle:
https://www.uops.info/table.html?search=vshufp&cb_lat=on&cb_tp=on&cb_uops=on&cb_ports=on&cb_SKL=on&cb_ICL=on&cb_measurements=on&cb_iaca30=on&cb_doc=on&cb_avx=on&cb_avx2=on

Therefore, the performed replacement of the shuffle is contra-productive on an Ice Lake processor.
Even with -march= icelake-client, Clang replaces the shuffle with vunpcklpd:

https://godbolt.org/z/MqtJXY

Same goes for mm256_shuffle_ps(,_,0xee) vunpckhpd.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions