mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
Fix lowering of VECTOR_SHUFFLE on SPU. Old algorithm
used to choke llc with the attached test. llvm-svn: 106411
This commit is contained in:
parent
705c2bd4c3
commit
a30e45e2d3
@ -1746,15 +1746,20 @@ static SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) {
|
||||
unsigned V0Elt = 0;
|
||||
bool monotonic = true;
|
||||
bool rotate = true;
|
||||
EVT maskVT; // which of the c?d instructions to use
|
||||
|
||||
if (EltVT == MVT::i8) {
|
||||
V2EltIdx0 = 16;
|
||||
maskVT = MVT::v16i8;
|
||||
} else if (EltVT == MVT::i16) {
|
||||
V2EltIdx0 = 8;
|
||||
maskVT = MVT::v8i16;
|
||||
} else if (EltVT == MVT::i32 || EltVT == MVT::f32) {
|
||||
V2EltIdx0 = 4;
|
||||
maskVT = MVT::v4i32;
|
||||
} else if (EltVT == MVT::i64 || EltVT == MVT::f64) {
|
||||
V2EltIdx0 = 2;
|
||||
maskVT = MVT::v2i64;
|
||||
} else
|
||||
llvm_unreachable("Unhandled vector type in LowerVECTOR_SHUFFLE");
|
||||
|
||||
@ -1800,16 +1805,16 @@ static SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) {
|
||||
// Compute mask and shuffle
|
||||
MachineFunction &MF = DAG.getMachineFunction();
|
||||
MachineRegisterInfo &RegInfo = MF.getRegInfo();
|
||||
unsigned VReg = RegInfo.createVirtualRegister(&SPU::R32CRegClass);
|
||||
EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy();
|
||||
// Initialize temporary register to 0
|
||||
SDValue InitTempReg =
|
||||
DAG.getCopyToReg(DAG.getEntryNode(), dl, VReg, DAG.getConstant(0, PtrVT));
|
||||
// Copy register's contents as index in SHUFFLE_MASK:
|
||||
SDValue ShufMaskOp =
|
||||
DAG.getNode(SPUISD::SHUFFLE_MASK, dl, MVT::v4i32,
|
||||
DAG.getTargetConstant(V2Elt, MVT::i32),
|
||||
DAG.getCopyFromReg(InitTempReg, dl, VReg, PtrVT));
|
||||
|
||||
// As SHUFFLE_MASK becomes a c?d instruction, feed it an address
|
||||
// R1 ($sp) is used here only as it is guaranteed to have last bits zero
|
||||
SDValue Pointer = DAG.getNode(SPUISD::IndirectAddr, dl, PtrVT,
|
||||
DAG.getRegister(SPU::R1, PtrVT),
|
||||
DAG.getConstant(V2Elt, MVT::i32));
|
||||
SDValue ShufMaskOp = DAG.getNode(SPUISD::SHUFFLE_MASK, dl,
|
||||
maskVT, Pointer);
|
||||
|
||||
// Use shuffle mask in SHUFB synthetic instruction:
|
||||
return DAG.getNode(SPUISD::SHUFB, dl, V1.getValueType(), V2, V1,
|
||||
ShufMaskOp);
|
||||
|
10
test/CodeGen/CellSPU/shuffles.ll
Normal file
10
test/CodeGen/CellSPU/shuffles.ll
Normal file
@ -0,0 +1,10 @@
|
||||
; RUN: llc --march=cellspu < %s | FileCheck %s
|
||||
|
||||
define <4 x float> @shuffle(<4 x float> %param1, <4 x float> %param2) {
|
||||
; CHECK: cwd {{\$.}}, 0($sp)
|
||||
; CHECK: shufb {{\$., \$4, \$3, \$.}}
|
||||
%val= shufflevector <4 x float> %param1, <4 x float> %param2, <4 x i32> <i32 4,i32 1,i32 2,i32 3>
|
||||
ret <4 x float> %val
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user