Skip to content

Commit

Permalink
Take account of boolean vector contents when promoting a build vector…
Browse files Browse the repository at this point in the history
… from i1 to some other type. rdar://problem/12210060

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162960 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
cooperp committed Aug 30, 2012
1 parent 9e3b6df commit 5dd9e21
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2913,8 +2913,24 @@ SDValue DAGTypeLegalizer::PromoteIntRes_BUILD_VECTOR(SDNode *N) {

SmallVector<SDValue, 8> Ops;
Ops.reserve(NumElems);
unsigned ExtendOp = ISD::ANY_EXTEND;
// Extending boolean constants needs to consider the
// value boolean vector constants take on this target and extend
// with sign or zeros appropriately.
if (OutVT.getVectorElementType() == MVT::i1) {
switch (TLI.getBooleanContents(true)) {
case TargetLowering::UndefinedBooleanContent:
break;
case TargetLowering::ZeroOrOneBooleanContent:
ExtendOp = ISD::ZERO_EXTEND;
break;
case TargetLowering::ZeroOrNegativeOneBooleanContent:
ExtendOp = ISD::SIGN_EXTEND;
break;
}
}
for (unsigned i = 0; i != NumElems; ++i) {
SDValue Op = DAG.getNode(ISD::ANY_EXTEND, dl, NOutVTElem, N->getOperand(i));
SDValue Op = DAG.getNode(ExtendOp, dl, NOutVTElem, N->getOperand(i));
Ops.push_back(Op);
}

Expand Down
16 changes: 16 additions & 0 deletions test/CodeGen/X86/vec_select.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
; RUN: llc < %s -march=x86 | FileCheck %s

; When legalizing the v4i1 constant, we need to consider the boolean contents
; For x86 a boolean vector constant is all ones so the constants in memory
; will be ~0U not 1.

; CHECK: .long 4294967295
; CHECK: .long 4294967295
; CHECK: .long 0
; CHECK: .long 0

; CHECK: test
define <4 x i8> @test(<4 x i8> %a, <4 x i8> %b) {
%sel = select <4 x i1> <i1 true, i1 true, i1 false, i1 false>, <4 x i8> %a, <4 x i8> %b
ret <4 x i8> %sel
}

0 comments on commit 5dd9e21

Please sign in to comment.