Allow sign-extending of i8 and i16 to i128 on SPU.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123912 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Kalle Raiskila 2011-01-20 15:49:06 +00:00
parent 9d32f60a6f
commit 5106b84506
3 changed files with 28 additions and 1 deletions

View 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

View 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)) &&

View 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
}