[PATCH] D80563: [X86][SSE] Convert PTEST to MOVMSK for allsign bits vector results.

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 26 08:38:58 PDT 2020


RKSimon created this revision.
RKSimon added reviewers: craig.topper, spatel, andreadb.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80563

Files:
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/X86/combine-ptest.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80563.266222.patch
Type: text/x-patch
Size: 5048 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200526/119799d6/attachment-0001.bin>


More information about the llvm-commits mailing list