forked from OSchip/llvm-project
GlobalISel: allow G_SELECT instructions for pointers.
llvm-svn: 288835
This commit is contained in:
parent
405e25cd6a
commit
f50f2f3d32
|
@ -488,7 +488,7 @@ public:
|
|||
/// \pre setBasicBlock or setMI must have been called.
|
||||
/// \pre \p Res, \p Op0 and \p Op1 must be generic virtual registers
|
||||
/// with the same type.
|
||||
/// \pre \p Tst must be a generic virtual register with scalar or
|
||||
/// \pre \p Tst must be a generic virtual register with scalar, pointer or
|
||||
/// vector type. If vector then it must have the same number of
|
||||
/// elements as the other parameters.
|
||||
///
|
||||
|
|
|
@ -392,11 +392,12 @@ MachineInstrBuilder MachineIRBuilder::buildFCmp(CmpInst::Predicate Pred,
|
|||
MachineInstrBuilder MachineIRBuilder::buildSelect(unsigned Res, unsigned Tst,
|
||||
unsigned Op0, unsigned Op1) {
|
||||
#ifndef NDEBUG
|
||||
assert((MRI->getType(Res).isScalar() || MRI->getType(Res).isVector()) &&
|
||||
LLT ResTy = MRI->getType(Res);
|
||||
assert((ResTy.isScalar() || ResTy.isVector() || ResTy.isPointer()) &&
|
||||
"invalid operand type");
|
||||
assert(MRI->getType(Res) == MRI->getType(Op0) &&
|
||||
MRI->getType(Res) == MRI->getType(Op1) && "type mismatch");
|
||||
if (MRI->getType(Res).isScalar())
|
||||
assert(ResTy == MRI->getType(Op0) && ResTy == MRI->getType(Op1) &&
|
||||
"type mismatch");
|
||||
if (ResTy.isScalar() || ResTy.isPointer())
|
||||
assert(MRI->getType(Tst).isScalar() && "type mismatch");
|
||||
else
|
||||
assert(MRI->getType(Tst).isVector() &&
|
||||
|
|
|
@ -761,6 +761,17 @@ define i32 @test_select(i1 %tst, i32 %lhs, i32 %rhs) {
|
|||
ret i32 %res
|
||||
}
|
||||
|
||||
; CHECK-LABEL: name: test_select_ptr
|
||||
; CHECK: [[TST:%[0-9]+]](s1) = COPY %w0
|
||||
; CHECK: [[LHS:%[0-9]+]](p0) = COPY %x1
|
||||
; CHECK: [[RHS:%[0-9]+]](p0) = COPY %x2
|
||||
; CHECK: [[RES:%[0-9]+]](p0) = G_SELECT [[TST]](s1), [[LHS]], [[RHS]]
|
||||
; CHECK: %x0 = COPY [[RES]]
|
||||
define i8* @test_select_ptr(i1 %tst, i8* %lhs, i8* %rhs) {
|
||||
%res = select i1 %tst, i8* %lhs, i8* %rhs
|
||||
ret i8* %res
|
||||
}
|
||||
|
||||
; CHECK-LABEL: name: test_fptosi
|
||||
; CHECK: [[FPADDR:%[0-9]+]](p0) = COPY %x0
|
||||
; CHECK: [[FP:%[0-9]+]](s32) = G_LOAD [[FPADDR]](p0)
|
||||
|
|
Loading…
Reference in New Issue