@@ -288,9 +288,8 @@ static bool processPHI(PHINode *P, LazyValueInfo *LVI, DominatorTree *DT,
288288}
289289
290290static bool processICmp (ICmpInst *Cmp, LazyValueInfo *LVI) {
291- // Only for signed relational comparisons of scalar integers.
292- if (Cmp->getType ()->isVectorTy () ||
293- !Cmp->getOperand (0 )->getType ()->isIntegerTy ())
291+ // Only for signed relational comparisons of integers.
292+ if (!Cmp->getOperand (0 )->getType ()->isIntOrIntVectorTy ())
294293 return false ;
295294
296295 if (!Cmp->isSigned ())
@@ -505,12 +504,8 @@ static bool processBinOp(BinaryOperator *BinOp, LazyValueInfo *LVI);
505504// because it is negation-invariant.
506505static bool processAbsIntrinsic (IntrinsicInst *II, LazyValueInfo *LVI) {
507506 Value *X = II->getArgOperand (0 );
508- Type *Ty = X->getType ();
509- if (!Ty->isIntegerTy ())
510- return false ;
511-
512507 bool IsIntMinPoison = cast<ConstantInt>(II->getArgOperand (1 ))->isOne ();
513- APInt IntMin = APInt::getSignedMinValue (Ty ->getScalarSizeInBits ());
508+ APInt IntMin = APInt::getSignedMinValue (X-> getType () ->getScalarSizeInBits ());
514509 ConstantRange Range = LVI->getConstantRangeAtUse (
515510 II->getOperandUse (0 ), /* UndefAllowed*/ IsIntMinPoison);
516511
@@ -679,15 +674,13 @@ static bool processCallSite(CallBase &CB, LazyValueInfo *LVI) {
679674 }
680675
681676 if (auto *WO = dyn_cast<WithOverflowInst>(&CB)) {
682- if (WO-> getLHS ()-> getType ()-> isIntegerTy () && willNotOverflow (WO, LVI)) {
677+ if (willNotOverflow (WO, LVI))
683678 return processOverflowIntrinsic (WO, LVI);
684- }
685679 }
686680
687681 if (auto *SI = dyn_cast<SaturatingInst>(&CB)) {
688- if (SI-> getType ()-> isIntegerTy () && willNotOverflow (SI, LVI)) {
682+ if (willNotOverflow (SI, LVI))
689683 return processSaturatingInst (SI, LVI);
690- }
691684 }
692685
693686 bool Changed = false ;
@@ -761,11 +754,10 @@ static bool narrowSDivOrSRem(BinaryOperator *Instr, const ConstantRange &LCR,
761754 const ConstantRange &RCR) {
762755 assert (Instr->getOpcode () == Instruction::SDiv ||
763756 Instr->getOpcode () == Instruction::SRem);
764- assert (!Instr->getType ()->isVectorTy ());
765757
766758 // Find the smallest power of two bitwidth that's sufficient to hold Instr's
767759 // operands.
768- unsigned OrigWidth = Instr->getType ()->getIntegerBitWidth ();
760+ unsigned OrigWidth = Instr->getType ()->getScalarSizeInBits ();
769761
770762 // What is the smallest bit width that can accommodate the entire value ranges
771763 // of both of the operands?
@@ -788,7 +780,7 @@ static bool narrowSDivOrSRem(BinaryOperator *Instr, const ConstantRange &LCR,
788780
789781 ++NumSDivSRemsNarrowed;
790782 IRBuilder<> B{Instr};
791- auto *TruncTy = Type::getIntNTy ( Instr->getContext (), NewWidth);
783+ auto *TruncTy = Instr->getType ()-> getWithNewBitWidth ( NewWidth);
792784 auto *LHS = B.CreateTruncOrBitCast (Instr->getOperand (0 ), TruncTy,
793785 Instr->getName () + " .lhs.trunc" );
794786 auto *RHS = B.CreateTruncOrBitCast (Instr->getOperand (1 ), TruncTy,
@@ -809,7 +801,6 @@ static bool expandUDivOrURem(BinaryOperator *Instr, const ConstantRange &XCR,
809801 Type *Ty = Instr->getType ();
810802 assert (Instr->getOpcode () == Instruction::UDiv ||
811803 Instr->getOpcode () == Instruction::URem);
812- assert (!Ty->isVectorTy ());
813804 bool IsRem = Instr->getOpcode () == Instruction::URem;
814805
815806 Value *X = Instr->getOperand (0 );
@@ -892,7 +883,6 @@ static bool narrowUDivOrURem(BinaryOperator *Instr, const ConstantRange &XCR,
892883 const ConstantRange &YCR) {
893884 assert (Instr->getOpcode () == Instruction::UDiv ||
894885 Instr->getOpcode () == Instruction::URem);
895- assert (!Instr->getType ()->isVectorTy ());
896886
897887 // Find the smallest power of two bitwidth that's sufficient to hold Instr's
898888 // operands.
@@ -905,12 +895,12 @@ static bool narrowUDivOrURem(BinaryOperator *Instr, const ConstantRange &XCR,
905895
906896 // NewWidth might be greater than OrigWidth if OrigWidth is not a power of
907897 // two.
908- if (NewWidth >= Instr->getType ()->getIntegerBitWidth ())
898+ if (NewWidth >= Instr->getType ()->getScalarSizeInBits ())
909899 return false ;
910900
911901 ++NumUDivURemsNarrowed;
912902 IRBuilder<> B{Instr};
913- auto *TruncTy = Type::getIntNTy ( Instr->getContext (), NewWidth);
903+ auto *TruncTy = Instr->getType ()-> getWithNewBitWidth ( NewWidth);
914904 auto *LHS = B.CreateTruncOrBitCast (Instr->getOperand (0 ), TruncTy,
915905 Instr->getName () + " .lhs.trunc" );
916906 auto *RHS = B.CreateTruncOrBitCast (Instr->getOperand (1 ), TruncTy,
@@ -929,9 +919,6 @@ static bool narrowUDivOrURem(BinaryOperator *Instr, const ConstantRange &XCR,
929919static bool processUDivOrURem (BinaryOperator *Instr, LazyValueInfo *LVI) {
930920 assert (Instr->getOpcode () == Instruction::UDiv ||
931921 Instr->getOpcode () == Instruction::URem);
932- if (Instr->getType ()->isVectorTy ())
933- return false ;
934-
935922 ConstantRange XCR = LVI->getConstantRangeAtUse (Instr->getOperandUse (0 ),
936923 /* UndefAllowed*/ false );
937924 // Allow undef for RHS, as we can assume it is division by zero UB.
@@ -946,7 +933,6 @@ static bool processUDivOrURem(BinaryOperator *Instr, LazyValueInfo *LVI) {
946933static bool processSRem (BinaryOperator *SDI, const ConstantRange &LCR,
947934 const ConstantRange &RCR, LazyValueInfo *LVI) {
948935 assert (SDI->getOpcode () == Instruction::SRem);
949- assert (!SDI->getType ()->isVectorTy ());
950936
951937 if (LCR.abs ().icmp (CmpInst::ICMP_ULT, RCR.abs ())) {
952938 SDI->replaceAllUsesWith (SDI->getOperand (0 ));
@@ -1006,7 +992,6 @@ static bool processSRem(BinaryOperator *SDI, const ConstantRange &LCR,
1006992static bool processSDiv (BinaryOperator *SDI, const ConstantRange &LCR,
1007993 const ConstantRange &RCR, LazyValueInfo *LVI) {
1008994 assert (SDI->getOpcode () == Instruction::SDiv);
1009- assert (!SDI->getType ()->isVectorTy ());
1010995
1011996 // Check whether the division folds to a constant.
1012997 ConstantRange DivCR = LCR.sdiv (RCR);
@@ -1064,9 +1049,6 @@ static bool processSDiv(BinaryOperator *SDI, const ConstantRange &LCR,
10641049static bool processSDivOrSRem (BinaryOperator *Instr, LazyValueInfo *LVI) {
10651050 assert (Instr->getOpcode () == Instruction::SDiv ||
10661051 Instr->getOpcode () == Instruction::SRem);
1067- if (Instr->getType ()->isVectorTy ())
1068- return false ;
1069-
10701052 ConstantRange LCR =
10711053 LVI->getConstantRangeAtUse (Instr->getOperandUse (0 ), /* AllowUndef*/ false );
10721054 // Allow undef for RHS, as we can assume it is division by zero UB.
@@ -1085,12 +1067,9 @@ static bool processSDivOrSRem(BinaryOperator *Instr, LazyValueInfo *LVI) {
10851067}
10861068
10871069static bool processAShr (BinaryOperator *SDI, LazyValueInfo *LVI) {
1088- if (SDI->getType ()->isVectorTy ())
1089- return false ;
1090-
10911070 ConstantRange LRange =
10921071 LVI->getConstantRangeAtUse (SDI->getOperandUse (0 ), /* UndefAllowed*/ false );
1093- unsigned OrigWidth = SDI->getType ()->getIntegerBitWidth ();
1072+ unsigned OrigWidth = SDI->getType ()->getScalarSizeInBits ();
10941073 ConstantRange NegOneOrZero =
10951074 ConstantRange (APInt (OrigWidth, (uint64_t )-1 , true ), APInt (OrigWidth, 1 ));
10961075 if (NegOneOrZero.contains (LRange)) {
@@ -1117,9 +1096,6 @@ static bool processAShr(BinaryOperator *SDI, LazyValueInfo *LVI) {
11171096}
11181097
11191098static bool processSExt (SExtInst *SDI, LazyValueInfo *LVI) {
1120- if (SDI->getType ()->isVectorTy ())
1121- return false ;
1122-
11231099 const Use &Base = SDI->getOperandUse (0 );
11241100 if (!LVI->getConstantRangeAtUse (Base, /* UndefAllowed*/ false )
11251101 .isAllNonNegative ())
@@ -1138,9 +1114,6 @@ static bool processSExt(SExtInst *SDI, LazyValueInfo *LVI) {
11381114}
11391115
11401116static bool processPossibleNonNeg (PossiblyNonNegInst *I, LazyValueInfo *LVI) {
1141- if (I->getType ()->isVectorTy ())
1142- return false ;
1143-
11441117 if (I->hasNonNeg ())
11451118 return false ;
11461119
@@ -1164,9 +1137,6 @@ static bool processUIToFP(UIToFPInst *UIToFP, LazyValueInfo *LVI) {
11641137}
11651138
11661139static bool processSIToFP (SIToFPInst *SIToFP, LazyValueInfo *LVI) {
1167- if (SIToFP->getType ()->isVectorTy ())
1168- return false ;
1169-
11701140 const Use &Base = SIToFP->getOperandUse (0 );
11711141 if (!LVI->getConstantRangeAtUse (Base, /* UndefAllowed*/ false )
11721142 .isAllNonNegative ())
@@ -1187,9 +1157,6 @@ static bool processSIToFP(SIToFPInst *SIToFP, LazyValueInfo *LVI) {
11871157static bool processBinOp (BinaryOperator *BinOp, LazyValueInfo *LVI) {
11881158 using OBO = OverflowingBinaryOperator;
11891159
1190- if (BinOp->getType ()->isVectorTy ())
1191- return false ;
1192-
11931160 bool NSW = BinOp->hasNoSignedWrap ();
11941161 bool NUW = BinOp->hasNoUnsignedWrap ();
11951162 if (NSW && NUW)
0 commit comments