Improve lowering of sext to i128 on SPU.
authorKalle Raiskila <kalle.raiskila@nokia.com>
Mon, 18 Oct 2010 09:34:19 +0000 (09:34 +0000)
committerKalle Raiskila <kalle.raiskila@nokia.com>
Mon, 18 Oct 2010 09:34:19 +0000 (09:34 +0000)
The old algorithm inserted a 'rotqmbyi' instruction which was
both redundant and wrong - it made shufb select bytes from the
wrong end of the input quad.

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

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

index 38b9f4e5233b5e258023f31e397659e3a8109757..2a82988ce0ac70d7e4bca73224731bd87c4381da 100644 (file)
@@ -2642,11 +2642,16 @@ static SDValue LowerSIGN_EXTEND(SDValue Op, SelectionDAG &DAG)
                  DAG.getNode(SPUISD::PREFSLOT2VEC, dl, mvt, Op0, Op0),
                  DAG.getConstant(31, MVT::i32));
 
+  // reinterpret as a i128 (SHUFB requires it). This gets lowered away.
+  SDValue extended = SDValue(DAG.getMachineNode(TargetOpcode::COPY_TO_REGCLASS, 
+                                        dl, Op0VT, Op0,
+                                        DAG.getTargetConstant(
+                                                  SPU::GPRCRegClass.getID(), 
+                                                  MVT::i32)), 0);
   // Shuffle bytes - Copy the sign bits into the upper 64 bits
   // and the input value into the lower 64 bits.
   SDValue extShuffle = DAG.getNode(SPUISD::SHUFB, dl, mvt,
-      DAG.getNode(ISD::ANY_EXTEND, dl, MVT::i128, Op0), sraVal, shufMask);
-
+        extended, sraVal, shufMask);
   return DAG.getNode(ISD::BIT_CONVERT, dl, MVT::i128, extShuffle);
 }
 
index 0c0b3599b110f14c582c041bca6d833269569bcd..8a5b609d79ac7c632216bce84d0c3afcae41eb12 100644 (file)
@@ -12,6 +12,7 @@ entry:
 ; CHECK:       long    269488144
 ; CHECK:       long    66051
 ; CHECK:       long    67438087
+; CHECK-NOT: rotqmbyi
 ; CHECK:       rotmai
 ; CHECK:       lqa
 ; CHECK:       shufb
@@ -25,6 +26,7 @@ entry:
 ; CHECK:       long    269488144
 ; CHECK:       long    269488144
 ; CHECK:       long    66051
+; CHECK-NOT: rotqmbyi
 ; CHECK:       rotmai
 ; CHECK:       lqa
 ; CHECK:       shufb
@@ -39,6 +41,7 @@ entry:
 ; CHECK:       long    269488144
 ; CHECK:       long    269488144
 ; CHECK:       long    66051
+; CHECK-NOT: rotqmbyi
 ; CHECK:       rotmai
 ; CHECK:       lqa
 ; CHECK:       shufb