From: Andrea Di Biagio Date: Wed, 15 Jan 2014 19:51:32 +0000 (+0000) Subject: [DAGCombiner] Fix a wrong check in method SimplifyVBinOp. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3cab648f220f354db06e4334b1da3ae1f417d16e;p=oota-llvm.git [DAGCombiner] Fix a wrong check in method SimplifyVBinOp. This fixes a regression intruced by r199135. Revision 199135 tried to simplify part of the logic in method DAGCombiner::SimplifyVBinOp introducing calls to method BuildVectorSDNode::isConstant(). However, that revision wrongly changed the check performed by method SimplifyVBinOp to identify dag nodes that can be folded. Before revision 199135, that method only tried to simplify vector binary operations if both operands were build_vector of Constant/ConstantFP/Undef only. After revision 199135, method SimplifyVBinop tried to simplify also vector binary operations with only one constant operand. This fixes the problem restoring the old behavior of SimplifyVBinOp. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199328 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index b0e14266bc4..0530dbc12b2 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -10391,8 +10391,8 @@ SDValue DAGCombiner::SimplifyVBinOp(SDNode *N) { if (LHS.getOpcode() == ISD::BUILD_VECTOR && RHS.getOpcode() == ISD::BUILD_VECTOR) { // Check if both vectors are constants. If not bail out. - if (!cast(LHS)->isConstant() && - !cast(RHS)->isConstant()) + if (!(cast(LHS)->isConstant() && + cast(RHS)->isConstant())) return SDValue(); SmallVector Ops; diff --git a/test/CodeGen/X86/vbinop-simplify-bug.ll b/test/CodeGen/X86/vbinop-simplify-bug.ll new file mode 100644 index 00000000000..81299ed4ff8 --- /dev/null +++ b/test/CodeGen/X86/vbinop-simplify-bug.ll @@ -0,0 +1,23 @@ +; RUN: llc %s -mtriple=x86_64-unknown-linux-gnu -mattr=sse2 -mcpu=corei7 + +; Revision 199135 introduced a wrong check in method +; DAGCombiner::SimplifyVBinOp in an attempt to refactor some code +; using the new method 'BuildVectorSDNode::isConstant' when possible. +; +; However the modified code in method SimplifyVBinOp now wrongly +; checks that the operands of a vector bin-op are both constants. +; +; With that wrong change, this test started failing because of a +; 'fatal error in the backend': +; Cannot select: 0x2e329d0: v4i32 = BUILD_VECTOR 0x2e2ea00, 0x2e2ea00, 0x2e2ea00, 0x2e2ea00 +; 0x2e2ea00: i32 = Constant<1> [ID=4] +; 0x2e2ea00: i32 = Constant<1> [ID=4] +; 0x2e2ea00: i32 = Constant<1> [ID=4] +; 0x2e2ea00: i32 = Constant<1> [ID=4] + +define <8 x i32> @reduced_test_case() { + %Shuff = shufflevector <8 x i32> zeroinitializer, <8 x i32> zeroinitializer, <8 x i32> + %B23 = sub <8 x i32> %Shuff, + ret <8 x i32> %B23 +} +