[PATCH] D34336: [x86] transform vector inc/dec to use -1 constant (PR33483)

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 18 15:53:42 PDT 2017


spatel created this revision.
Herald added a subscriber: mcrosier.

Convert vector increment or decrement to sub/add with an all-ones constant:

  add X, <1, 1...> --> sub X, <-1, -1...>
  sub X, <1, 1...> --> add X, <-1, -1...>

The all-ones vector constant can be materialized using a pcmpeq instruction that is commonly recognized as an idiom (has no register dependency and/or has no latency), so that's better than loading a splat 1 constant.

The SSE and AVX1/2 diffs look like what I expected - we prefer 'pcmpeq' even over a folded load. AVX512 uses 'vpternlogd' for 512-bit vectors. Is that optimal?

This should fix:
https://bugs.llvm.org/show_bug.cgi?id=33483


https://reviews.llvm.org/D34336

Files:
  lib/Target/X86/X86ISelLowering.cpp
  test/CodeGen/X86/avg.ll
  test/CodeGen/X86/avx-intrinsics-x86-upgrade.ll
  test/CodeGen/X86/avx-intrinsics-x86.ll
  test/CodeGen/X86/avx-logic.ll
  test/CodeGen/X86/avx-vperm2x128.ll
  test/CodeGen/X86/avx2-intrinsics-x86-upgrade.ll
  test/CodeGen/X86/avx2-logic.ll
  test/CodeGen/X86/select.ll
  test/CodeGen/X86/sse2-intrinsics-x86-upgrade.ll
  test/CodeGen/X86/vec_ctbits.ll
  test/CodeGen/X86/vector-tzcnt-128.ll
  test/CodeGen/X86/vector-tzcnt-256.ll
  test/CodeGen/X86/vector-tzcnt-512.ll
  test/CodeGen/X86/widen_arith-1.ll
  test/CodeGen/X86/widen_arith-2.ll
  test/CodeGen/X86/widen_arith-3.ll
  test/CodeGen/X86/widen_cast-2.ll
  test/CodeGen/X86/widen_cast-3.ll
  test/CodeGen/X86/widen_cast-4.ll
  test/CodeGen/X86/widen_conv-1.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34336.102980.patch
Type: text/x-patch
Size: 151242 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170618/aca6b8da/attachment-0001.bin>


More information about the llvm-commits mailing list