[all-commits] [llvm/llvm-project] 410667: [X86][SSE] Convert PTEST to MOVMSK for allsign bit...

Simon Pilgrim via All-commits all-commits at lists.llvm.org
Wed May 27 03:26:53 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 410667f1b74c614d9382f180d29f5aa1e42cc5c9
      https://github.com/llvm/llvm-project/commit/410667f1b74c614d9382f180d29f5aa1e42cc5c9
  Author: Simon Pilgrim <llvm-dev at redking.me.uk>
  Date:   2020-05-27 (Wed, 27 May 2020)

  Changed paths:
    M llvm/lib/Target/X86/X86ISelLowering.cpp
    M llvm/test/CodeGen/X86/combine-ptest.ll

  Log Message:
  -----------
  [X86][SSE] Convert PTEST to MOVMSK for allsign bits vector results

If we are using PTEST to check 'allsign bits' vector elements we can use MOVMSK to extract the signbits directly and perform the comparison on the scalar value.

For vXi16 cases, as we don't have a MOVMSK for this type, we must mask each signbit out of a PMOVMSKB v2Xi8 result, which folds into the TEST comparison.

If this allows us to remove a vector op (via the SimplifyMultipleUseDemandedBits call) this is consistently faster than a PTEST (https://godbolt.org/z/ziJUst).

I'm investigating whether we ever get regressions without the SimplifyMultipleUseDemandedBits call, even if this means we don't remove a vector op, but that has exposed some other poor codegen issues that I'm still investigating and would have to wait for a later patch.

Suggested on PR42035 to avoid unnecessary ashr(x,bw-1)/pcmpgt(0,x) sign splat patterns feeding into ptest.

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


  Commit: 35963f6d8519d7384c9040d629cbb4cf6ff96de8
      https://github.com/llvm/llvm-project/commit/35963f6d8519d7384c9040d629cbb4cf6ff96de8
  Author: Simon Pilgrim <llvm-dev at redking.me.uk>
  Date:   2020-05-27 (Wed, 27 May 2020)

  Changed paths:
    M llvm/lib/Transforms/Vectorize/VPlanValue.h

  Log Message:
  -----------
  VPlanValue.h - reduce unnecessary includes to forward declarations. NFC.


Compare: https://github.com/llvm/llvm-project/compare/f2fad3f703aa...35963f6d8519


More information about the All-commits mailing list