llvm.org GIT mirror llvm / 55604d9
Don't use EnforceSmallerThan for EnforceVectorSubVectorTypeIs. EnforceSmallerThan doesn't handle vectors quite right and should really enforce that vectors have the same number of elements. Add explicit checks for vector element count differing in EnforceVectorSubVectorTypeIs instead. This removes some unnecessary type checks in X86GenDAGISel.inc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200091 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 6 years ago
1 changed file(s) with 53 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
579579 /// vector type specified by VTOperand.
580580 bool EEVT::TypeSet::EnforceVectorSubVectorTypeIs(EEVT::TypeSet &VTOperand,
581581 TreePattern &TP) {
582 if (TP.hasError())
583 return false;
584
582585 // "This" must be a vector and "VTOperand" must be a vector.
583586 bool MadeChange = false;
584587 MadeChange |= EnforceVector(TP);
585588 MadeChange |= VTOperand.EnforceVector(TP);
586589
587 // "This" must be larger than "VTOperand."
588 MadeChange |= VTOperand.EnforceSmallerThan(*this, TP);
590 // If one side is known to be integer or known to be FP but the other side has
591 // no information, get at least the type integrality info in there.
592 if (!hasFloatingPointTypes())
593 MadeChange |= VTOperand.EnforceInteger(TP);
594 else if (!hasIntegerTypes())
595 MadeChange |= VTOperand.EnforceFloatingPoint(TP);
596 if (!VTOperand.hasFloatingPointTypes())
597 MadeChange |= EnforceInteger(TP);
598 else if (!VTOperand.hasIntegerTypes())
599 MadeChange |= EnforceFloatingPoint(TP);
600
601 assert(!isCompletelyUnknown() && !VTOperand.isCompletelyUnknown() &&
602 "Should have a type list now");
589603
590604 // If we know the vector type, it forces the scalar types to agree.
605 // Also force one vector to have more elements than the other.
591606 if (isConcrete()) {
592607 MVT IVT = getConcrete();
608 unsigned NumElems = IVT.getVectorNumElements();
593609 IVT = IVT.getVectorElementType();
594610
595611 EEVT::TypeSet EltTypeSet(IVT.SimpleTy, TP);
596612 MadeChange |= VTOperand.EnforceVectorEltTypeIs(EltTypeSet, TP);
613
614 // Only keep types that have less elements than VTOperand.
615 TypeSet InputSet(VTOperand);
616
617 for (unsigned i = 0; i != VTOperand.TypeVec.size(); ++i) {
618 assert(isVector(VTOperand.TypeVec[i]) && "EnforceVector didn't work");
619 if (MVT(VTOperand.TypeVec[i]).getVectorNumElements() >= NumElems) {
620 VTOperand.TypeVec.erase(VTOperand.TypeVec.begin()+i--);
621 MadeChange = true;
622 }
623 }
624 if (VTOperand.TypeVec.empty()) { // FIXME: Really want an SMLoc here!
625 TP.error("Type inference contradiction found, forcing '" +
626 InputSet.getName() + "' to have less vector elements than '" +
627 getName() + "'");
628 return false;
629 }
597630 } else if (VTOperand.isConcrete()) {
598631 MVT IVT = VTOperand.getConcrete();
632 unsigned NumElems = IVT.getVectorNumElements();
599633 IVT = IVT.getVectorElementType();
600634
601635 EEVT::TypeSet EltTypeSet(IVT.SimpleTy, TP);
602636 MadeChange |= EnforceVectorEltTypeIs(EltTypeSet, TP);
637
638 // Only keep types that have more elements than 'this'.
639 TypeSet InputSet(*this);
640
641 for (unsigned i = 0; i != TypeVec.size(); ++i) {
642 assert(isVector(TypeVec[i]) && "EnforceVector didn't work");
643 if (MVT(TypeVec[i]).getVectorNumElements() <= NumElems) {
644 TypeVec.erase(TypeVec.begin()+i--);
645 MadeChange = true;
646 }
647 }
648 if (TypeVec.empty()) { // FIXME: Really want an SMLoc here!
649 TP.error("Type inference contradiction found, forcing '" +
650 InputSet.getName() + "' to have more vector elements than '" +
651 VTOperand.getName() + "'");
652 return false;
653 }
603654 }
604655
605656 return MadeChange;