@@ -1295,24 +1295,16 @@ void SCCPInstVisitor::visitCastInst(CastInst &I) {
1295
1295
return (void )markConstant (&I, C);
1296
1296
}
1297
1297
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) {
1299
1301
auto &LV = getValueState (&I);
1300
1302
ConstantRange OpRange =
1301
1303
getConstantRange (OpSt, I.getSrcTy (), /* UndefAllowed=*/ false );
1302
1304
1303
1305
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
-
1314
1306
ConstantRange Res =
1315
- OpRange.castOp (I.getOpcode (), DL. getTypeSizeInBits ( DestTy));
1307
+ OpRange.castOp (I.getOpcode (), DestTy-> getScalarSizeInBits ( ));
1316
1308
mergeInValue (LV, &I, ValueLatticeElement::getRange (Res));
1317
1309
} else
1318
1310
markOverdefined (&I);
0 commit comments