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

via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 4 08:08:39 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?

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


More information about the llvm-commits mailing list