[all-commits] [llvm/llvm-project] 4a2303: [X86] Fix `(shift X, (xor Y, N-1))` -> `(shift X, ...

goldsteinn via All-commits all-commits at lists.llvm.org
Tue Feb 28 21:25:43 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4a23031fac1a58f6cf05d07f915633930532eafa
      https://github.com/llvm/llvm-project/commit/4a23031fac1a58f6cf05d07f915633930532eafa
  Author: Noah Goldstein <goldstein.w.n at gmail.com>
  Date:   2023-02-28 (Tue, 28 Feb 2023)

  Changed paths:
    M llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
    A llvm/test/CodeGen/X86/pr61038.ll

  Log Message:
  -----------
  [X86] Fix `(shift X, (xor Y, N-1))` -> `(shift X, (not Y))` by properly inserting `not Y` into DAG. [#61038]

Previously not inserting the `-1` in `not Y` (`xor Y, -1`) into the
DAG. Not inserting `-1` as a DAG node comes up as a bug when doing
`(xor (shl 1, A), B)` -> `(btc A, B)`. `btc` requires `B` (dst) to be
a register.

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


  Commit: 05ca9ebc0433b4e19fc67c1dd023414bc6357f09
      https://github.com/llvm/llvm-project/commit/05ca9ebc0433b4e19fc67c1dd023414bc6357f09
  Author: Noah Goldstein <goldstein.w.n at gmail.com>
  Date:   2023-02-28 (Tue, 28 Feb 2023)

  Changed paths:
    M llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
    M llvm/test/CodeGen/X86/pr61038.ll

  Log Message:
  -----------
  [X86] Make `(shift X (xor/sub N-1, Y))` -> `(shift X, (not Y))` check for one use.

`(xor/sub N-1, Y)` -> `(not Y)` is minorly preferable (especially for
`(sub N-1, Y)` where it saves an instruction), but isn't worth
potentially creating an extra instruction for.

So, only do the transformation if `(xor/sub N-1, Y)` has one use.

Reviewed By: RKSimon

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


  Commit: a98ee27416916c3f8af4cd229e0a633423d6d9a3
      https://github.com/llvm/llvm-project/commit/a98ee27416916c3f8af4cd229e0a633423d6d9a3
  Author: Noah Goldstein <goldstein.w.n at gmail.com>
  Date:   2023-02-28 (Tue, 28 Feb 2023)

  Changed paths:
    M llvm/lib/Target/X86/X86.td
    M llvm/lib/Target/X86/X86ISelLowering.cpp
    M llvm/lib/Target/X86/X86TargetTransformInfo.h
    M llvm/test/CodeGen/X86/avx512-hadd-hsub.ll
    M llvm/test/CodeGen/X86/min-legal-vector-width.ll
    M llvm/test/CodeGen/X86/pr57340.ll
    M llvm/test/CodeGen/X86/shuffle-as-shifts.ll

  Log Message:
  -----------
  [X86] Add `TuningPreferShiftShuffle` for when Shifts are preferable to shuffles.

SKX has an objectively faster shift than shuffle, on all other targets
the two have equal performance (with maybe a slight preference for
shifts because p5 is a more common bottleneck).

Reviewed By: RKSimon

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


Compare: https://github.com/llvm/llvm-project/compare/65f68812d399...a98ee2741691


More information about the All-commits mailing list