File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -1442,8 +1442,12 @@ void SCCPInstVisitor::visitCastInst(CastInst &I) {
14421442 OpSt.asConstantRange (I.getSrcTy (), /* UndefAllowed=*/ false );
14431443
14441444 Type *DestTy = I.getDestTy ();
1445- ConstantRange Res =
1446- OpRange.castOp (I.getOpcode (), DestTy->getScalarSizeInBits ());
1445+ ConstantRange Res = ConstantRange::getEmpty (DestTy->getScalarSizeInBits ());
1446+ if (auto *Trunc = dyn_cast<TruncInst>(&I))
1447+ Res = OpRange.truncate (DestTy->getScalarSizeInBits (),
1448+ Trunc->getNoWrapKind ());
1449+ else
1450+ Res = OpRange.castOp (I.getOpcode (), DestTy->getScalarSizeInBits ());
14471451 mergeInValue (LV, &I, ValueLatticeElement::getRange (Res));
14481452 } else
14491453 markOverdefined (&I);
Original file line number Diff line number Diff line change @@ -1441,8 +1441,7 @@ define void @trunc_nuw_i1_dominating_icmp_ne_0(i8 %x) {
14411441; CHECK-NEXT: [[ICMP:%.*]] = icmp ne i8 [[X:%.*]], 0
14421442; CHECK-NEXT: br i1 [[ICMP]], label [[BB1:%.*]], label [[BB2:%.*]]
14431443; CHECK: bb1:
1444- ; CHECK-NEXT: [[C1:%.*]] = trunc nuw i8 [[X]] to i1
1445- ; CHECK-NEXT: call void @use(i1 [[C1]])
1444+ ; CHECK-NEXT: call void @use(i1 true)
14461445; CHECK-NEXT: ret void
14471446; CHECK: bb2:
14481447; CHECK-NEXT: ret void
You can’t perform that action at this time.
0 commit comments