diff --git a/llvm/lib/Target/MSP430/MSP430ISelLowering.h b/llvm/lib/Target/MSP430/MSP430ISelLowering.h --- a/llvm/lib/Target/MSP430/MSP430ISelLowering.h +++ b/llvm/lib/Target/MSP430/MSP430ISelLowering.h @@ -130,6 +130,8 @@ MachineBasicBlock *EmitShiftInstr(MachineInstr &MI, MachineBasicBlock *BB) const; + EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, + EVT VT) const override; private: SDValue LowerCCCCallTo(SDValue Chain, SDValue Callee, CallingConv::ID CallConv, bool isVarArg, diff --git a/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp b/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp --- a/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp +++ b/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp @@ -1603,3 +1603,11 @@ MI.eraseFromParent(); // The pseudo instruction is gone now. return BB; } + +EVT MSP430TargetLowering::getSetCCResultType(const DataLayout &DL, LLVMContext &, + EVT VT) const { + if (!VT.isVector()) + return getPointerTy(DL); + + return VT.changeVectorElementTypeToInteger(); +} diff --git a/llvm/test/CodeGen/MSP430/get-setcc-result-type.ll b/llvm/test/CodeGen/MSP430/get-setcc-result-type.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/MSP430/get-setcc-result-type.ll @@ -0,0 +1,22 @@ +; RUN: llc -march=msp430 < %s | FileCheck %s + +target datalayout = "e-p:16:8:8-i8:8:8-i8:8:8-i32:8:8" +target triple = "msp430-generic-generic" + +define void @getSetCCResultType(<1 x i16>* %p, <1 x i16>* %q) { +; CHECK-LABEL: getSetCCResultType: +; CHECK: tst 0(r12) +; CHECK-NEXT: mov r2, r13 +; CHECK-NEXT: rra r13 +; CHECK-NEXT: and #1, r13 +; CHECK-NEXT: clr r14 +; CHECK-NEXT: sub r13, r14 +; CHECK-NEXT: mov r14, 0(r12) +; CHECK-NEXT: ret +entry: + %0 = load <1 x i16>, <1 x i16>* %p, align 16 + %cmp = icmp eq <1 x i16> %0, zeroinitializer + %sext = sext <1 x i1> %cmp to <1 x i16> + store <1 x i16> %sext, <1 x i16>* %p, align 16 + ret void +}