[llvm-commits] [llvm] r169684 - in /llvm/trunk: lib/CodeGen/SelectionDAG/DAGCombiner.cpp test/CodeGen/X86/2011-11-30-or.ll test/CodeGen/X86/fold-pcmpeqd-2.ll test/CodeGen/X86/sse2-blend.ll

Duncan Sands baldrick at free.fr
Mon Dec 10 00:21:22 PST 2012


Hi Craig,

On 08/12/12 23:49, Craig Topper wrote:
> Author: ctopper
> Date: Sat Dec  8 16:49:19 2012
> New Revision: 169684
>
> URL: http://llvm.org/viewvc/llvm-project?rev=169684&view=rev
> Log:
> Teach DAG combine to handle vector logical operations with vectors of all 1s or all 0s. These cases can show up when vectors are split for legalizing. Fix some tests that were dependent on these cases not being combined.
>
> Modified:
>      llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
>      llvm/trunk/test/CodeGen/X86/2011-11-30-or.ll
>      llvm/trunk/test/CodeGen/X86/fold-pcmpeqd-2.ll
>      llvm/trunk/test/CodeGen/X86/sse2-blend.ll
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=169684&r1=169683&r2=169684&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Sat Dec  8 16:49:19 2012
> @@ -2427,6 +2427,18 @@
>     if (VT.isVector()) {
>       SDValue FoldedVOp = SimplifyVBinOp(N);
>       if (FoldedVOp.getNode()) return FoldedVOp;
> +
> +    // fold (and x, 0) -> 0, vector edition
> +    if (ISD::isBuildVectorAllZeros(N0.getNode()))
> +      return N0;
> +    if (ISD::isBuildVectorAllZeros(N1.getNode()))
> +      return N1;
> +
> +    // fold (and x, -1) -> x, vector edition
> +    if (ISD::isBuildVectorAllOnes(N0.getNode()))
> +      return N1;
> +    if (ISD::isBuildVectorAllOnes(N1.getNode()))
> +      return N0;

if constants are canonicalized to the right-hand side then you don't need to
test both sides.  If they aren't canonicalized to the right-hand side then they
probably should be!

Ciao, Duncan.



More information about the llvm-commits mailing list