[X86][FP16] Don't crash when lowering SELECT on fp16 vectors

This is a regression from f187948162
This commit is contained in:
Benjamin Kramer 2022-07-18 13:39:14 +02:00
parent f372142740
commit 9234a7c0df
2 changed files with 37 additions and 4 deletions

View File

@ -24994,10 +24994,12 @@ SDValue X86TargetLowering::LowerSELECT(SDValue Op, SelectionDAG &DAG) const {
MVT VT = Op1.getSimpleValueType();
SDValue CC;
if (isSoftFP16(VT))
return DAG.getBitcast(MVT::f16, DAG.getNode(ISD::SELECT, DL, MVT::i16, Cond,
DAG.getBitcast(MVT::i16, Op1),
DAG.getBitcast(MVT::i16, Op2)));
if (isSoftFP16(VT)) {
MVT NVT = VT.changeTypeToInteger();
return DAG.getBitcast(VT, DAG.getNode(ISD::SELECT, DL, NVT, Cond,
DAG.getBitcast(NVT, Op1),
DAG.getBitcast(NVT, Op2)));
}
// Lower FP selects into a CMP/AND/ANDN/OR sequence when the necessary SSE ops
// are available or VBLENDV if AVX is available.

View File

@ -1238,4 +1238,35 @@ define half @fcopysign(half %x, half %y) {
declare half @llvm.fabs.f16(half)
declare half @llvm.copysign.f16(half, half)
define <8 x half> @select(i1 %c, <8 x half> %x, <8 x half> %y) {
; CHECK-LIBCALL-LABEL: select:
; CHECK-LIBCALL: # %bb.0:
; CHECK-LIBCALL-NEXT: testb $1, %dil
; CHECK-LIBCALL-NEXT: jne .LBB23_2
; CHECK-LIBCALL-NEXT: # %bb.1:
; CHECK-LIBCALL-NEXT: movaps %xmm1, %xmm0
; CHECK-LIBCALL-NEXT: .LBB23_2:
; CHECK-LIBCALL-NEXT: retq
;
; BWON-F16C-LABEL: select:
; BWON-F16C: # %bb.0:
; BWON-F16C-NEXT: testb $1, %dil
; BWON-F16C-NEXT: jne .LBB23_2
; BWON-F16C-NEXT: # %bb.1:
; BWON-F16C-NEXT: vmovaps %xmm1, %xmm0
; BWON-F16C-NEXT: .LBB23_2:
; BWON-F16C-NEXT: retq
;
; CHECK-I686-LABEL: select:
; CHECK-I686: # %bb.0:
; CHECK-I686-NEXT: testb $1, {{[0-9]+}}(%esp)
; CHECK-I686-NEXT: jne .LBB23_2
; CHECK-I686-NEXT: # %bb.1:
; CHECK-I686-NEXT: movaps %xmm1, %xmm0
; CHECK-I686-NEXT: .LBB23_2:
; CHECK-I686-NEXT: retl
%s = select i1 %c, <8 x half> %x, <8 x half> %y
ret <8 x half> %s
}
attributes #0 = { nounwind }