Skip to content

Commit

Permalink
[X86] Special handle for v1i1 during ExtractBitFromMaskVector
Browse files Browse the repository at this point in the history
Fixes llvm#64322

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D156855
  • Loading branch information
phoebewang authored and doru1004 committed Aug 3, 2023
1 parent 2af04d7 commit 10425b2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
13 changes: 13 additions & 0 deletions llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17619,6 +17619,19 @@ static SDValue ExtractBitFromMaskVector(SDValue Op, SelectionDAG &DAG,
unsigned NumElts = VecVT.getVectorNumElements();
// Extending v8i1/v16i1 to 512-bit get better performance on KNL
// than extending to 128/256bit.
if (NumElts == 1) {
if (Subtarget.hasDQI()) {
Vec = DAG.getNode(ISD::INSERT_SUBVECTOR, dl, MVT::v8i1,
DAG.getUNDEF(MVT::v8i1), Vec,
DAG.getIntPtrConstant(0, dl));
return DAG.getBitcast(MVT::i8, Vec);
}
Vec = DAG.getNode(ISD::INSERT_SUBVECTOR, dl, MVT::v16i1,
DAG.getUNDEF(MVT::v16i1), Vec,
DAG.getIntPtrConstant(0, dl));
return DAG.getNode(ISD::TRUNCATE, dl, MVT::i8,
DAG.getBitcast(MVT::i16, Vec));
}
MVT ExtEltVT = (NumElts <= 8) ? MVT::getIntegerVT(128 / NumElts) : MVT::i8;
MVT ExtVecVT = MVT::getVectorVT(ExtEltVT, NumElts);
SDValue Ext = DAG.getNode(ISD::SIGN_EXTEND, dl, ExtVecVT, Vec);
Expand Down
21 changes: 21 additions & 0 deletions llvm/test/CodeGen/X86/pr64322.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=icelake-server | FileCheck %s

@G = global <1 x i1> <i1 true>
@G.1 = global i1 false

define void @foo(i32 %x) {
; CHECK-LABEL: foo:
; CHECK: # %bb.0:
; CHECK-NEXT: movq G@GOTPCREL(%rip), %rax
; CHECK-NEXT: kmovb (%rax), %k0
; CHECK-NEXT: kmovd %k0, %eax
; CHECK-NEXT: andb $1, %al
; CHECK-NEXT: movq G.1@GOTPCREL(%rip), %rcx
; CHECK-NEXT: movb %al, (%rcx)
; CHECK-NEXT: retq
%LGV = load <1 x i1>, ptr @G
%E = extractelement <1 x i1> %LGV, i32 %x
store i1 %E, ptr @G.1
ret void
}

0 comments on commit 10425b2

Please sign in to comment.