Allow sign-extending of i8 and i16 to i128 on SPU.
authorKalle Raiskila <kalle.raiskila@nokia.com>
Thu, 20 Jan 2011 15:49:06 +0000 (15:49 +0000)
committerKalle Raiskila <kalle.raiskila@nokia.com>
Thu, 20 Jan 2011 15:49:06 +0000 (15:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123912 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/CellSPU/README.txt
lib/Target/CellSPU/SPUISelLowering.cpp
test/CodeGen/CellSPU/sext128.ll

index 0e7ad3533e914b8d20cb1ef16ad1c8c9465b8627..3e7e0b68e8e623304e75d8837bcb4b28ebcfe5c5 100644 (file)
@@ -55,7 +55,7 @@ TODO:
 * i128 support:
 
   * zero extension, any extension: done
-  * sign extension: needed
+  * sign extension: done
   * arithmetic operators (add, sub, mul, div): needed
   * logical operations (and, or, shl, srl, sra, xor, nor, nand): needed
 
index 36c8bd5684669459f451d17a683b8a5a032ce47f..e218fb92d1c1ac18ce8fb087826886418e7a0c4f 100644 (file)
@@ -2719,6 +2719,12 @@ static SDValue LowerSIGN_EXTEND(SDValue Op, SelectionDAG &DAG)
   SDValue Op0 = Op.getOperand(0);
   MVT Op0VT = Op0.getValueType().getSimpleVT();
 
+  // extend i8 & i16 via i32
+  if (Op0VT == MVT::i8 || Op0VT == MVT::i16) {
+    Op0 = DAG.getNode(ISD::SIGN_EXTEND, dl, MVT::i32, Op0);
+    Op0VT = MVT::i32;
+  }
+
   // The type to extend to needs to be a i128 and
   // the type to extend from needs to be i64 or i32.
   assert((OpVT == MVT::i128 && (Op0VT == MVT::i64 || Op0VT == MVT::i32)) &&
index 027c1c58afbc0627e42f148dc223990829b1edf1..6ae9aa51202fd839ebaf39ccac70f43ca3f71991 100644 (file)
@@ -48,3 +48,24 @@ entry:
 }
 
 declare i32 @myfunc(float)
+
+define i128 @func1(i8 %u) {
+entry:
+; CHECK: xsbh
+; CHECK: xshw
+; CHECK: rotmai
+; CHECK: shufb
+; CHECK: bi $lr
+      %0 = sext i8 %u to i128
+      ret i128 %0
+}
+
+define i128 @func2(i16 %u) {
+entry:
+; CHECK: xshw
+; CHECK: rotmai
+; CHECK: shufb
+; CHECK: bi $lr
+      %0 = sext i16 %u to i128
+      ret i128 %0
+}