Allow load from constant on SPU.
authorKalle Raiskila <kalle.raiskila@nokia.com>
Fri, 4 Mar 2011 12:00:11 +0000 (12:00 +0000)
committerKalle Raiskila <kalle.raiskila@nokia.com>
Fri, 4 Mar 2011 12:00:11 +0000 (12:00 +0000)
A 'load <4 x i32>* null' crashes llc before this fix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126995 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/CellSPU/SPUISelDAGToDAG.cpp
test/CodeGen/CellSPU/loads.ll
test/CodeGen/CellSPU/stores.ll

index d2261562e721bb14eec0a29e6ba377b491a0a08d..9351ffdc0b7fd005b5028664409b0fd9ef61643d 100644 (file)
@@ -321,12 +321,17 @@ SPUDAGToDAGISel::SelectAFormAddr(SDNode *Op, SDValue N, SDValue &Base,
   // These match the addr256k operand type:
   EVT OffsVT = MVT::i16;
   SDValue Zero = CurDAG->getTargetConstant(0, OffsVT);
+  int64_t val;
 
   switch (N.getOpcode()) {
   case ISD::Constant:
+    val = dyn_cast<ConstantSDNode>(N.getNode())->getSExtValue();
+    Base = CurDAG->getTargetConstant( val , MVT::i32);
+    Index = Zero;
+    return true; break;
   case ISD::ConstantPool:
   case ISD::GlobalAddress:
-    report_fatal_error("SPU SelectAFormAddr: Constant/Pool/Global not lowered.");
+    report_fatal_error("SPU SelectAFormAddr: Pool/Global not lowered.");
     /*NOTREACHED*/
 
   case ISD::TargetConstant:
index 03d7ad1153a17487b8a11cd8ec66fcb09c094a27..4771752f5f4c7954b9471c9aa298d45add25bf2d 100644 (file)
@@ -50,3 +50,10 @@ define i32 @load_misaligned( i32* %ptr ){
   %rv = load i32* %ptr, align 2
   ret i32 %rv
 }
+
+define <4 x i32> @load_null_vec( ) {
+;CHECK: lqa
+;CHECK: bi $lr
+       %rv = load <4 x i32>* null
+       ret <4 x i32> %rv
+}
index 7e0bf06b4e454314d5ce52cf3cb564330c5de074..6ca5b0892304f7fec76fa9e540059f4f016feda9 100644 (file)
@@ -171,3 +171,11 @@ define void @store_v8( <8 x float> %val, <8 x float>* %ptr )
        store <8 x float> %val, <8 x float>* %ptr
        ret void
 }
+
+define void @store_null_vec( <4 x i32> %val ) {
+; FIXME - this is for some reason compiled into a il+stqd, not a sta. 
+;CHECK: stqd
+;CHECK: bi $lr
+       store <4 x i32> %val, <4 x i32>* null
+       ret void
+}