r272245 - [X86] Reuse the EmitX86Select routine to handle the select for masked palignr too.

Craig Topper via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 8 22:15:01 PDT 2016


Author: ctopper
Date: Thu Jun  9 00:15:00 2016
New Revision: 272245

URL: http://llvm.org/viewvc/llvm-project?rev=272245&view=rev
Log:
[X86] Reuse the EmitX86Select routine to handle the select for masked palignr too.

Modified:
    cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=272245&r1=272244&r2=272245&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jun  9 00:15:00 2016
@@ -6334,17 +6334,16 @@ static Value *EmitX86MaskedLoad(CodeGenF
 }
 
 static Value *EmitX86Select(CodeGenFunction &CGF,
-                            SmallVectorImpl<Value *> &Ops) {
+                            Value *Mask, Value *Op0, Value *Op1) {
 
   // If the mask is all ones just return first argument.
-  if (const auto *C = dyn_cast<Constant>(Ops[0]))
+  if (const auto *C = dyn_cast<Constant>(Mask))
     if (C->isAllOnesValue())
-      return Ops[1];
+      return Op0;
 
-  Value *MaskVec = getMaskVecValue(CGF, Ops[0],
-                                   Ops[1]->getType()->getVectorNumElements());
+  Mask = getMaskVecValue(CGF, Mask, Op0->getType()->getVectorNumElements());
 
-  return CGF.Builder.CreateSelect(MaskVec, Ops[1], Ops[2]);
+  return CGF.Builder.CreateSelect(Mask, Op0, Op1);
 }
 
 Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
@@ -6702,15 +6701,7 @@ Value *CodeGenFunction::EmitX86BuiltinEx
     if (Ops.size() == 3)
       return Align;
 
-    // If the mask is all ones just emit the align operation.
-    if (const auto *C = dyn_cast<Constant>(Ops[4]))
-      if (C->isAllOnesValue())
-        return Align;
-
-    llvm::VectorType *MaskTy = llvm::VectorType::get(Builder.getInt1Ty(),
-                                                     NumElts);
-    llvm::Value *Mask = Builder.CreateBitCast(Ops[4], MaskTy, "cast");
-    return Builder.CreateSelect(Mask, Align, Ops[3]);
+    return EmitX86Select(*this, Ops[4], Align, Ops[3]);
   }
 
   case X86::BI__builtin_ia32_pslldqi256: {
@@ -6812,7 +6803,7 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   case X86::BI__builtin_ia32_selectpd_128:
   case X86::BI__builtin_ia32_selectpd_256:
   case X86::BI__builtin_ia32_selectpd_512:
-    return EmitX86Select(*this, Ops);
+    return EmitX86Select(*this, Ops[0], Ops[1], Ops[2]);
   // 3DNow!
   case X86::BI__builtin_ia32_pswapdsf:
   case X86::BI__builtin_ia32_pswapdsi: {




More information about the cfe-commits mailing list