Generate better select code by allowing the target to use scalar select, and not...
authorNadav Rotem <nrotem@apple.com>
Sun, 2 Sep 2012 08:20:07 +0000 (08:20 +0000)
committerNadav Rotem <nrotem@apple.com>
Sun, 2 Sep 2012 08:20:07 +0000 (08:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163086 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
test/CodeGen/ARM/2012-08-30-select.ll

index c334f1fba5ffb733687823312797fcb5aabc9845..18a71691d49a6b2860732bdbcbc09a3139092cfc 100644 (file)
@@ -475,10 +475,9 @@ SDValue VectorLegalizer::ExpandSELECT(SDValue Op) {
   // What is the size of each element in the vector mask.
   EVT BitTy = MaskTy.getScalarType();
 
-  // Turn the mask into an all-one or all-zero word.
-  Mask = DAG.getAnyExtOrTrunc(Mask, DL, BitTy);
-  Mask = DAG.getNode(ISD::SIGN_EXTEND_INREG, DL, BitTy, Mask,
-                     DAG.getValueType(MVT::i1));
+  Mask = DAG.getNode(ISD::SELECT, DL, BitTy, Mask,
+          DAG.getConstant(APInt::getAllOnesValue(BitTy.getSizeInBits()), BitTy),
+          DAG.getConstant(3, BitTy));
 
   // Broadcast the mask so that the entire vector is all-one or all zero.
   SmallVector<SDValue, 8> Ops(NumElem, Mask);
index 8021533b1bbcd67900877e478b9e4efb9e1e2e23..4c94ac9dbf0599ce7027d9fd067a08fbcabe744e 100644 (file)
@@ -2,6 +2,8 @@
 ; rdar://12201387
 
 ;CHECK: select_s_v_v
+;CHECK: it  eq
+;CHECK-NEXT: moveq.w r2, #-1
 ;CHECK: vbsl
 ;CHECK: bx
 define <16 x i8> @select_s_v_v(i32 %avail, i8* %bar) {