[llvm] r181682 - Fix PR15950 A bug in DAG Combiner about undef mask

Bob Wilson bob.wilson at apple.com
Mon May 13 12:03:39 PDT 2013


This patch introduced a redundant copy of the "Begin" variable.  I've removed it in svn 181721.

On May 12, 2013, at 7:07 PM, Hao Liu <Hao.Liu at arm.com> wrote:

> Author: haoliu
> Date: Sun May 12 21:07:05 2013
> New Revision: 181682
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=181682&view=rev
> Log:
> Fix PR15950 A bug in DAG Combiner about undef mask
> 
> Added:
>    llvm/trunk/test/CodeGen/ARM/2013-05-13-DAGCombiner-undef-mask.ll
> Modified:
>    llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
> 
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=181682&r1=181681&r2=181682&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Sun May 12 21:07:05 2013
> @@ -9254,19 +9254,34 @@ static SDValue partitionShuffleOfConcats
>   for (unsigned I = 0; I != NumConcats; ++I) {
>     // Make sure we're dealing with a copy.
>     unsigned Begin = I * NumElemsPerConcat;
> -    if (SVN->getMaskElt(Begin) % NumElemsPerConcat != 0)
> -      return SDValue();
> +    bool AllUndef = true, NoUndef = true;
> +    for (unsigned J = Begin; J != Begin + NumElemsPerConcat; ++J) {
> +      if (SVN->getMaskElt(J) >= 0)
> +        AllUndef = false;
> +      else
> +        NoUndef = false;
> +    }
> 
> -    for (unsigned J = 1; J != NumElemsPerConcat; ++J) {
> -      if (SVN->getMaskElt(Begin + J - 1) + 1 != SVN->getMaskElt(Begin + J))
> +    if (NoUndef) {
> +      unsigned Begin = I * NumElemsPerConcat;
> +      if (SVN->getMaskElt(Begin) % NumElemsPerConcat != 0)
>         return SDValue();
> -    }
> 
> -    unsigned FirstElt = SVN->getMaskElt(Begin) / NumElemsPerConcat;
> -    if (FirstElt < N0.getNumOperands())
> -      Ops.push_back(N0.getOperand(FirstElt));
> -    else
> -      Ops.push_back(N1.getOperand(FirstElt - N0.getNumOperands()));
> +      for (unsigned J = 1; J != NumElemsPerConcat; ++J)
> +        if (SVN->getMaskElt(Begin + J - 1) + 1 != SVN->getMaskElt(Begin + J))
> +          return SDValue();
> +
> +      unsigned FirstElt = SVN->getMaskElt(Begin) / NumElemsPerConcat;
> +      if (FirstElt < N0.getNumOperands())
> +        Ops.push_back(N0.getOperand(FirstElt));
> +      else
> +        Ops.push_back(N1.getOperand(FirstElt - N0.getNumOperands()));
> +
> +    } else if (AllUndef) {
> +      Ops.push_back(DAG.getUNDEF(N0.getOperand(0).getValueType()));
> +    } else { // Mixed with general masks and undefs, can't do optimization.
> +      return SDValue();
> +    }
>   }
> 
>   return DAG.getNode(ISD::CONCAT_VECTORS, N->getDebugLoc(), VT, Ops.data(),
> 
> Added: llvm/trunk/test/CodeGen/ARM/2013-05-13-DAGCombiner-undef-mask.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2013-05-13-DAGCombiner-undef-mask.ll?rev=181682&view=auto
> ==============================================================================
> --- llvm/trunk/test/CodeGen/ARM/2013-05-13-DAGCombiner-undef-mask.ll (added)
> +++ llvm/trunk/test/CodeGen/ARM/2013-05-13-DAGCombiner-undef-mask.ll Sun May 12 21:07:05 2013
> @@ -0,0 +1,10 @@
> +; RUN: llc < %s
> +target triple = "armv7-none-linux-gnueabi"
> +
> +define <3 x i64> @shuffle(i1 %dec1, i1 %dec0, <3 x i64> %b) {
> +entry:
> +  %.sink = select i1 %dec1, <3 x i64> %b, <3 x i64> zeroinitializer
> +  %.sink15 = select i1 %dec0, <3 x i64> %b, <3 x i64> zeroinitializer
> +  %vecinit7 = shufflevector <3 x i64> %.sink, <3 x i64> %.sink15, <3 x i32> <i32 0, i32 4, i32 undef>
> +  ret <3 x i64> %vecinit7
> +}
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list