Revert "[x86] fold vector (X > -1) & Y to shift+andn"
authorHans Wennborg <hans@chromium.org>
Mon, 15 Nov 2021 11:07:02 +0000 (12:07 +0100)
committerHans Wennborg <hans@chromium.org>
Mon, 15 Nov 2021 11:35:49 +0000 (12:35 +0100)
commit5be64d416481c59dba5faae5e8b8a6fecb578082
tree1b59fc94ac0c77680f129c6939bfe7396a7187b7
parent9fec50f001b1ab86ff36c6e92336ae1c1d3fcdef
Revert "[x86] fold vector (X > -1) & Y to shift+andn"

This casued assertion failures:

  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:9446:
  void llvm::SelectionDAG::ReplaceAllUsesWith(llvm::SDNode *, llvm::SDNode *):
  Assertion `(!From->hasAnyUseOfValue(i) || From->getValueType(i) == To->getValueType(i))
  && "Cannot use this version of ReplaceAllUsesWith!"' failed.

See comment on the code review.

(Had to update some expectations in test/CodeGen/X86/vselect-zero.ll
 manually due to other changes having landed after the reverted one.)

> and (pcmpgt X, -1), Y --> pandn (vsrai X, BitWidth-1), Y
>
> This avoids the -1 constant vector in favor of an arithmetic shift
> instruction if it exists (the ISA is still not complete after all
> these years...).
>
> We catch this pattern late in combining by matching PCMPGT, so it
> should not interfere with more general folds.
>
> Differential Revision: https://reviews.llvm.org/D113603

This reverts commit bf5748a1af0d2f6f9396d9dc6ac89d15de41eee7.
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/vector-pcmp.ll
llvm/test/CodeGen/X86/vselect-zero.ll