mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Add support for legalization of vector SHL/SRA/SRL instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141667 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6c6f28ffe4
commit
6fe4e51547
@ -989,6 +989,31 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) {
|
||||
#endif
|
||||
assert(0 && "Do not know how to legalize this operator!");
|
||||
|
||||
case ISD::SRA:
|
||||
case ISD::SRL:
|
||||
case ISD::SHL: {
|
||||
// Scalarize vector SRA/SRL/SHL.
|
||||
EVT VT = Node->getValueType(0);
|
||||
assert(VT.isVector() && "Unable to legalize non-vector shift");
|
||||
assert(TLI.isTypeLegal(VT.getScalarType())&& "Element type must be legal");
|
||||
unsigned NumElem = VT.getVectorNumElements();
|
||||
|
||||
SmallVector<SDValue, 8> Scalars;
|
||||
for (unsigned Idx = 0; Idx < NumElem; Idx++) {
|
||||
SDValue Ex = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl,
|
||||
VT.getScalarType(),
|
||||
Node->getOperand(0), DAG.getIntPtrConstant(Idx));
|
||||
SDValue Sh = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl,
|
||||
VT.getScalarType(),
|
||||
Node->getOperand(1), DAG.getIntPtrConstant(Idx));
|
||||
Scalars.push_back(DAG.getNode(Node->getOpcode(), dl,
|
||||
VT.getScalarType(), Ex, Sh));
|
||||
}
|
||||
Result = DAG.getNode(ISD::BUILD_VECTOR, dl, Node->getValueType(0),
|
||||
&Scalars[0], Scalars.size());
|
||||
break;
|
||||
}
|
||||
|
||||
case ISD::BUILD_VECTOR:
|
||||
switch (TLI.getOperationAction(ISD::BUILD_VECTOR, Node->getValueType(0))) {
|
||||
default: assert(0 && "This action is not supported yet!");
|
||||
|
11
test/CodeGen/X86/2011-10-11-srl.ll
Normal file
11
test/CodeGen/X86/2011-10-11-srl.ll
Normal file
@ -0,0 +1,11 @@
|
||||
; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=corei7-avx -promote-elements -mattr=-sse41
|
||||
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
define void @m387(<2 x i8>* %p, <2 x i16>* %q) {
|
||||
%t = load <2 x i8>* %p
|
||||
%r = sext <2 x i8> %t to <2 x i16>
|
||||
store <2 x i16> %r, <2 x i16>* %q
|
||||
ret void
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user