Skip to content

Commit

Permalink
[X86] combineToExtendBoolVectorInReg - don't use changeVectorElementT…
Browse files Browse the repository at this point in the history
…ype to create the bool vector type

Converting a (simple) vXf32 type to a vXi1 type isn't guaranteed to be simple, causing the MVT type to be invalid.

Fixes #64627
  • Loading branch information
RKSimon committed Aug 13, 2023
1 parent 1c822e1 commit 512a6c5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44137,7 +44137,7 @@ static SDValue combineToExtendBoolVectorInReg(
Vec = DAG.getNode(ISD::AND, DL, VT, Vec, BitMask);

// Compare against the bitmask and extend the result.
EVT CCVT = VT.changeVectorElementType(MVT::i1);
EVT CCVT = EVT::getVectorVT(*DAG.getContext(), MVT::i1, NumElts);
Vec = DAG.getSetCC(DL, CCVT, Vec, BitMask, ISD::SETEQ);
Vec = DAG.getSExtOrTrunc(Vec, DL, VT);

Expand Down
22 changes: 22 additions & 0 deletions llvm/test/CodeGen/X86/vector-reduce-fadd.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1898,6 +1898,28 @@ define double @test_v16f64_undef(<16 x double> %a0) {
ret double %1
}

define float @PR64627() {
; SSE-LABEL: PR64627:
; SSE: # %bb.0:
; SSE-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
; SSE-NEXT: retq
;
; AVX-LABEL: PR64627:
; AVX: # %bb.0:
; AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
; AVX-NEXT: retq
;
; AVX512-LABEL: PR64627:
; AVX512: # %bb.0:
; AVX512-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
; AVX512-NEXT: retq
%1 = bitcast i5 0 to <5 x i1>
%2 = select <5 x i1> %1, <5 x float> zeroinitializer, <5 x float> <float 1.0, float 1.0, float 1.0, float 1.0, float 1.0>
%3 = call float @llvm.vector.reduce.fadd.v5f32(float -0.0, <5 x float> %2)
ret float %3
}
declare float @llvm.vector.reduce.fadd.v5f32(float, <5 x float>)

declare float @llvm.vector.reduce.fadd.f32.v2f32(float, <2 x float>)
declare float @llvm.vector.reduce.fadd.f32.v4f32(float, <4 x float>)
declare float @llvm.vector.reduce.fadd.f32.v8f32(float, <8 x float>)
Expand Down

0 comments on commit 512a6c5

Please sign in to comment.