From 768ebcdf631baa1b18dc65a5983a237b307a99c2 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 10 May 2013 14:09:52 +0000 Subject: DAGCombiner: Generate a correct constant for vector types when folding (xor (and)) into (and (not)). PR15948. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181597 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 3 +-- test/CodeGen/X86/xor.ll | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 700ee12072..c54dffbb13 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -3464,8 +3464,7 @@ SDValue DAGCombiner::visitXOR(SDNode *N) { if (N0.getOpcode() == ISD::AND && N0.getNode()->hasOneUse() && N0->getOperand(1) == N1) { SDValue X = N0->getOperand(0); - SDValue NotX = DAG.getNode(ISD::XOR, X.getDebugLoc(), VT, X, - DAG.getConstant(APInt::getAllOnesValue(VT.getSizeInBits()), VT)); + SDValue NotX = DAG.getNOT(X.getDebugLoc(), X, VT); AddToWorkList(NotX.getNode()); return DAG.getNode(ISD::AND, N->getDebugLoc(), VT, NotX, N1); } diff --git a/test/CodeGen/X86/xor.ll b/test/CodeGen/X86/xor.ll index 2408bfe72c..574bb7817e 100644 --- a/test/CodeGen/X86/xor.ll +++ b/test/CodeGen/X86/xor.ll @@ -154,3 +154,14 @@ define i32 @test9(i32 %a) nounwind { ; X32: notl [[REG:%[a-z]+]] ; X32: andl {{.*}}[[REG:%[a-z]+]] } + +; PR15948 +define <4 x i32> @test10(<4 x i32> %a) nounwind { + %1 = and <4 x i32> %a, + %2 = xor <4 x i32> %1, + ret <4 x i32> %2 +; X64: test10: +; X64: andnps +; X32: test10: +; X32: andnps +} -- cgit v1.2.3