[llvm] [KnownBits] Improve minimum denominator bounds for sdiv (PR #227264)

via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 5 00:41:46 PDT 2026


anandkvinu wrote:

> > > > Oh gotcha. Yeah just make sure you are setting all the known ones/zeros via bitwise or/and instead of setting them one bit at a time.
> > > 
> > > 
> > > TEST(KnownBitsTest, NonZeroDenomSDiv) { KnownBits Num = KnownBits::makeConstant(APInt(4, -8, true));
> > > KnownBits X(4); KnownBits Mask = KnownBits::makeConstant(APInt(4, 0b0100)); KnownBits Denom = X & Mask;
> > > KnownBits Result = KnownBits::sdiv(Num, Denom);
> > > KnownBits Answer(4); Answer.One.setHighBits(3);
> > > EXPECT_EQ(Result, Answer); }
> > > can i go with this and push?
> > 
> > 
> > Probably look at other examples in the file. Otherwise probably would be good to do that for the `i8` cases I suggested prior too.
> 
> Sure. I have added those test cases for i8 and i32 in a similar way. Tested and verified. Thank you for the input.

@ZERICO2005 requesting review.

https://github.com/llvm/llvm-project/pull/227264


More information about the llvm-commits mailing list