[all-commits] [llvm/llvm-project] 300e12: [PowerPC] Disable perfect shuffle by default

Qiu Chaofan via All-commits all-commits at lists.llvm.org
Tue Mar 15 01:02:06 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 300e1293de635adbe651030de5c8ebd3263458b2
      https://github.com/llvm/llvm-project/commit/300e1293de635adbe651030de5c8ebd3263458b2
  Author: Qiu Chaofan <qiucofan at cn.ibm.com>
  Date:   2022-03-15 (Tue, 15 Mar 2022)

  Changed paths:
    M llvm/lib/Target/PowerPC/PPCISelLowering.cpp
    M llvm/test/CodeGen/PowerPC/2006-08-11-RetVector.ll
    M llvm/test/CodeGen/PowerPC/aix-p9-xxinsertw-xxextractuw.ll
    M llvm/test/CodeGen/PowerPC/aix-vsx-splatimm.ll
    M llvm/test/CodeGen/PowerPC/aix32-p8-scalar_vector_conversions.ll
    M llvm/test/CodeGen/PowerPC/extract-and-store.ll
    M llvm/test/CodeGen/PowerPC/load-and-splat.ll
    M llvm/test/CodeGen/PowerPC/p8altivec-shuffles-pred.ll
    M llvm/test/CodeGen/PowerPC/perfect-shuffle.ll
    M llvm/test/CodeGen/PowerPC/ppc-32bit-build-vector.ll
    M llvm/test/CodeGen/PowerPC/pr27078.ll
    M llvm/test/CodeGen/PowerPC/scalar_vector_test_4.ll
    M llvm/test/CodeGen/PowerPC/test-vector-insert.ll
    M llvm/test/CodeGen/PowerPC/vec_extract_p9.ll
    M llvm/test/CodeGen/PowerPC/vec_perf_shuffle.ll
    M llvm/test/CodeGen/PowerPC/vec_shuffle_p8vector.ll

  Log Message:
  -----------
  [PowerPC] Disable perfect shuffle by default

We are going to remove the old 'perfect shuffle' optimization since it
brings performance penalty in hot loop around vectors. For example, in
following loop sharing the same mask:

  %v.1 = shufflevector ... <0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27>
  %v.2 = shufflevector ... <0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27>

The generated instructions will be `vmrglw-vmrghw-vmrglw-vmrghw` instead
of `vperm-vperm`. In some large loop cases, this causes 20%+ performance
penalty.

The original attempt to resolve this is to pre-record masks of every
shufflevector operation in DAG, but that is somewhat complex and brings
unnecessary computation (to scan all nodes) in optimization. Here we
disable it by default. There're indeed some cases becoming worse after
this, which will be fixed in a more careful way in future patches.

Reviewed By: jsji

Differential Revision: https://reviews.llvm.org/D121082




More information about the All-commits mailing list