llvm.org GIT mirror llvm / 2e50619
Reapply 154397. Original message: Fix a dagcombine optimization which assumes that the vsetcc result type is always of the same size as the compared values. This is ture for SSE/AVX/NEON but not for all targets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154490 91177308-0d34-0410-b5e6-96231b3b80d8 Nadav Rotem 8 years ago
1 changed file(s) with 18 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
43534353 // Only do this before legalize for now.
43544354 if (VT.isVector() && !LegalOperations) {
43554355 EVT N0VT = N0.getOperand(0).getValueType();
4356 // We know that the # elements of the results is the same as the
4357 // # elements of the compare (and the # elements of the compare result
4358 // for that matter). Check to see that they are the same size. If so,
4359 // we know that the element size of the sext'd result matches the
4360 // element size of the compare operands.
4361 if (VT.getSizeInBits() == N0VT.getSizeInBits())
4356 // On some architectures (such as SSE/NEON/etc) the SETCC result type is
4357 // of the same size as the compared operands. Only optimize sext(setcc())
4358 // if this is the case.
4359 EVT SVT = TLI.getSetCCResultType(N0VT);
4360
4361 // We know that the # elements of the results is the same as the
4362 // # elements of the compare (and the # elements of the compare result
4363 // for that matter). Check to see that they are the same size. If so,
4364 // we know that the element size of the sext'd result matches the
4365 // element size of the compare operands.
4366 if (VT.getSizeInBits() == SVT.getSizeInBits())
43624367 return DAG.getSetCC(N->getDebugLoc(), VT, N0.getOperand(0),
43634368 N0.getOperand(1),
43644369 cast(N0.getOperand(2))->get());
43724377 EVT MatchingVectorType =
43734378 EVT::getVectorVT(*DAG.getContext(), MatchingElementType,
43744379 N0VT.getVectorNumElements());
4375 SDValue VsetCC =
4376 DAG.getSetCC(N->getDebugLoc(), MatchingVectorType, N0.getOperand(0),
4377 N0.getOperand(1),
4378 cast(N0.getOperand(2))->get());
4379 return DAG.getSExtOrTrunc(VsetCC, N->getDebugLoc(), VT);
4380
4381 if (SVT == MatchingVectorType) {
4382 SDValue VsetCC = DAG.getSetCC(N->getDebugLoc(), MatchingVectorType,
4383 N0.getOperand(0), N0.getOperand(1),
4384 cast(N0.getOperand(2))->get());
4385 return DAG.getSExtOrTrunc(VsetCC, N->getDebugLoc(), VT);
4386 }
43804387 }
43814388 }
43824389