Skip to content

Commit 6631907

Browse files
committed
[InstCombine] use isKnownNonNegative to reduce code duplication; NFC
We may be able to make the ValueTracking wrapper smarter in the future (for example, analyze a simple recurrence), so this will automatically benefit if that happens.
1 parent b3e8e43 commit 6631907

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,10 +1503,8 @@ Instruction *InstCombinerImpl::visitSExt(SExtInst &CI) {
15031503
unsigned SrcBitSize = SrcTy->getScalarSizeInBits();
15041504
unsigned DestBitSize = DestTy->getScalarSizeInBits();
15051505

1506-
// If we know that the value being extended is positive, we can use a zext
1507-
// instead.
1508-
KnownBits Known = computeKnownBits(Src, 0, &CI);
1509-
if (Known.isNonNegative())
1506+
// If the value being extended is zero or positive, use a zext instead.
1507+
if (isKnownNonNegative(Src, DL, 0, &AC, &CI, &DT))
15101508
return CastInst::Create(Instruction::ZExt, Src, DestTy);
15111509

15121510
// Try to extend the entire expression tree to the wide destination type.

0 commit comments

Comments
 (0)