[llvm] [AMDGPU] prevent shrinking udiv/urem if operands exceed smax_bitwidth (PR #116733)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 19 01:49:07 PST 2024


================
@@ -1193,6 +1193,17 @@ int AMDGPUCodeGenPrepareImpl::getDivNumBits(BinaryOperator &I, Value *Num,
                                             Value *Den, unsigned AtLeast,
                                             bool IsSigned) const {
   const DataLayout &DL = Mod->getDataLayout();
+  if (!IsSigned) {
+    KnownBits Known = computeKnownBits(Num, DL, 0, AC, &I);
+    // We know all bits are used for division for Operand > smax_bitwidth
----------------
jayfoad wrote:

Please try to make the comment more precise. What is smax_bitwidth? What does "Operand > smax_bitwidth" really mean?

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


More information about the llvm-commits mailing list