[X86] Fix a crash when returning a <1 x i1> value>

llvm-svn: 321595
This commit is contained in:
Craig Topper 2017-12-31 07:38:30 +00:00
parent 1d0e2e82bc
commit 7ba1b76854
2 changed files with 23 additions and 0 deletions

View File

@ -2143,6 +2143,10 @@ static SDValue lowerMasksToReg(const SDValue &ValArg, const EVT &ValLoc,
const SDLoc &Dl, SelectionDAG &DAG) {
EVT ValVT = ValArg.getValueType();
if (ValVT == MVT::v1i1)
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, Dl, ValLoc, ValArg,
DAG.getIntPtrConstant(0, Dl));
if ((ValVT == MVT::v8i1 && (ValLoc == MVT::i8 || ValLoc == MVT::i32)) ||
(ValVT == MVT::v16i1 && (ValLoc == MVT::i16 || ValLoc == MVT::i32))) {
// Two stage lowering might be required

View File

@ -410,3 +410,22 @@ define i32 @test12(i32 %a1, i32 %a2, i32 %b1) {
%res1 = select i1 %cond, i32 %res, i32 0
ret i32 %res1
}
define <1 x i1> @test13(<1 x i1>* %foo) {
; ALL_X64-LABEL: test13:
; ALL_X64: ## %bb.0:
; ALL_X64-NEXT: movzbl (%rdi), %eax
; ALL_X64-NEXT: andl $1, %eax
; ALL_X64-NEXT: ## kill: def %al killed %al killed %eax
; ALL_X64-NEXT: retq
;
; KNL_X32-LABEL: test13:
; KNL_X32: ## %bb.0:
; KNL_X32-NEXT: movl {{[0-9]+}}(%esp), %eax
; KNL_X32-NEXT: movzbl (%eax), %eax
; KNL_X32-NEXT: andl $1, %eax
; KNL_X32-NEXT: ## kill: def %al killed %al killed %eax
; KNL_X32-NEXT: retl
%bar = load <1 x i1>, <1 x i1>* %foo
ret <1 x i1> %bar
}