[llvm-commits] [llvm] r123912 - in /llvm/trunk: lib/Target/CellSPU/README.txt lib/Target/CellSPU/SPUISelLowering.cpp test/CodeGen/CellSPU/sext128.ll
Kalle Raiskila
kalle.raiskila at nokia.com
Thu Jan 20 07:49:06 PST 2011
Author: kraiskil
Date: Thu Jan 20 09:49:06 2011
New Revision: 123912
URL: http://llvm.org/viewvc/llvm-project?rev=123912&view=rev
Log:
Allow sign-extending of i8 and i16 to i128 on SPU.
Modified:
llvm/trunk/lib/Target/CellSPU/README.txt
llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp
llvm/trunk/test/CodeGen/CellSPU/sext128.ll
Modified: llvm/trunk/lib/Target/CellSPU/README.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/README.txt?rev=123912&r1=123911&r2=123912&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CellSPU/README.txt (original)
+++ llvm/trunk/lib/Target/CellSPU/README.txt Thu Jan 20 09:49:06 2011
@@ -55,7 +55,7 @@
* 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
Modified: llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp?rev=123912&r1=123911&r2=123912&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp Thu Jan 20 09:49:06 2011
@@ -2719,6 +2719,12 @@
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)) &&
Modified: llvm/trunk/test/CodeGen/CellSPU/sext128.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/CellSPU/sext128.ll?rev=123912&r1=123911&r2=123912&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/CellSPU/sext128.ll (original)
+++ llvm/trunk/test/CodeGen/CellSPU/sext128.ll Thu Jan 20 09:49:06 2011
@@ -48,3 +48,24 @@
}
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
+}
More information about the llvm-commits
mailing list