@@ -1295,24 +1295,16 @@ void SCCPInstVisitor::visitCastInst(CastInst &I) {
12951295 return (void )markConstant (&I, C);
12961296 }
12971297
1298- if (I.getDestTy ()->isIntegerTy () && I.getSrcTy ()->isIntOrIntVectorTy ()) {
1298+ // Ignore bitcasts, as they may change the number of vector elements.
1299+ if (I.getDestTy ()->isIntegerTy () && I.getSrcTy ()->isIntOrIntVectorTy () &&
1300+ I.getOpcode () != Instruction::BitCast) {
12991301 auto &LV = getValueState (&I);
13001302 ConstantRange OpRange =
13011303 getConstantRange (OpSt, I.getSrcTy (), /* UndefAllowed=*/ false );
13021304
13031305 Type *DestTy = I.getDestTy ();
1304- // Vectors where all elements have the same known constant range are treated
1305- // as a single constant range in the lattice. When bitcasting such vectors,
1306- // there is a mis-match between the width of the lattice value (single
1307- // constant range) and the original operands (vector). Go to overdefined in
1308- // that case.
1309- if (I.getOpcode () == Instruction::BitCast &&
1310- I.getOperand (0 )->getType ()->isVectorTy () &&
1311- OpRange.getBitWidth () < DL.getTypeSizeInBits (DestTy))
1312- return (void )markOverdefined (&I);
1313-
13141306 ConstantRange Res =
1315- OpRange.castOp (I.getOpcode (), DL. getTypeSizeInBits ( DestTy));
1307+ OpRange.castOp (I.getOpcode (), DestTy-> getScalarSizeInBits ( ));
13161308 mergeInValue (LV, &I, ValueLatticeElement::getRange (Res));
13171309 } else
13181310 markOverdefined (&I);
0 commit comments