llvm.org GIT mirror llvm / 71a494d
simplify by using ShuffleVectorInst::getMaskValue. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149029 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 7 years ago
1 changed file(s) with 8 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
786786 // Undefined shuffle mask -> undefined value.
787787 if (isa(Mask)) return UndefValue::get(V1->getType());
788788
789 unsigned MaskNumElts = cast(Mask->getType())->getNumElements();
790 unsigned SrcNumElts = cast(V1->getType())->getNumElements();
791 Type *EltTy = cast(V1->getType())->getElementType();
789 unsigned MaskNumElts = Mask->getType()->getVectorNumElements();
790 unsigned SrcNumElts = V1->getType()->getVectorNumElements();
791 Type *EltTy = V1->getType()->getVectorElementType();
792792
793793 // Loop over the shuffle mask, evaluating each element.
794794 SmallVector Result;
795795 for (unsigned i = 0; i != MaskNumElts; ++i) {
796 Constant *InElt = Mask->getAggregateElement(i);
797 if (InElt == 0) return 0;
798
799 if (isa(InElt)) {
796 int Elt = ShuffleVectorInst::getMaskValue(Mask, i);
797 if (Elt == -1) {
800798 Result.push_back(UndefValue::get(EltTy));
801799 continue;
802800 }
803 unsigned Elt = cast(InElt)->getZExtValue();
804 if (Elt >= SrcNumElts*2)
801 Constant *InElt;
802 if (unsigned(Elt) >= SrcNumElts*2)
805803 InElt = UndefValue::get(EltTy);
806 else if (Elt >= SrcNumElts)
804 else if (unsigned(Elt) >= SrcNumElts)
807805 InElt = V2->getAggregateElement(Elt - SrcNumElts);
808806 else
809807 InElt = V1->getAggregateElement(Elt);