[llvm-commits] [llvm] r112422 - in /llvm/trunk: lib/Target/CellSPU/SPUISelLowering.cpp test/CodeGen/CellSPU/shuffles.ll
Kalle Raiskila
kalle.raiskila at nokia.com
Sun Aug 29 05:41:50 PDT 2010
Author: kraiskil
Date: Sun Aug 29 07:41:50 2010
New Revision: 112422
URL: http://llvm.org/viewvc/llvm-project?rev=112422&view=rev
Log:
Fix lowering of INSERT_VECTOR_ELT in SPU.
The IDX was treated as byte index, not element index.
Modified:
llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp
llvm/trunk/test/CodeGen/CellSPU/shuffles.ll
Modified: llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp?rev=112422&r1=112421&r2=112422&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp Sun Aug 29 07:41:50 2010
@@ -2053,20 +2053,21 @@
SDValue IdxOp = Op.getOperand(2);
DebugLoc dl = Op.getDebugLoc();
EVT VT = Op.getValueType();
+ EVT eltVT = ValOp.getValueType();
// use 0 when the lane to insert to is 'undef'
- int64_t Idx=0;
+ int64_t Offset=0;
if (IdxOp.getOpcode() != ISD::UNDEF) {
ConstantSDNode *CN = cast<ConstantSDNode>(IdxOp);
assert(CN != 0 && "LowerINSERT_VECTOR_ELT: Index is not constant!");
- Idx = (CN->getSExtValue());
+ Offset = (CN->getSExtValue()) * eltVT.getSizeInBits()/8;
}
EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy();
// Use $sp ($1) because it's always 16-byte aligned and it's available:
SDValue Pointer = DAG.getNode(SPUISD::IndirectAddr, dl, PtrVT,
DAG.getRegister(SPU::R1, PtrVT),
- DAG.getConstant(Idx, PtrVT));
+ DAG.getConstant(Offset, PtrVT));
// widen the mask when dealing with half vectors
EVT maskVT = EVT::getVectorVT(*(DAG.getContext()), VT.getVectorElementType(),
128/ VT.getVectorElementType().getSizeInBits());
Modified: llvm/trunk/test/CodeGen/CellSPU/shuffles.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/CellSPU/shuffles.ll?rev=112422&r1=112421&r2=112422&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/CellSPU/shuffles.ll (original)
+++ llvm/trunk/test/CodeGen/CellSPU/shuffles.ll Sun Aug 29 07:41:50 2010
@@ -31,3 +31,11 @@
ret void
}
+define <4 x float> @test_insert_1(<4 x float> %vparam, float %eltparam) {
+;CHECK: cwd $5, 4($sp)
+;CHECK: shufb $3, $4, $3, $5
+;CHECK: bi $lr
+ %rv = insertelement <4 x float> %vparam, float %eltparam, i32 1
+ ret <4 x float> %rv
+}
+
More information about the llvm-commits
mailing list