[llvm] [AMDGPU] Use correct number of bits needed for div/rem shrinking (PR #80622)
    Jeffrey Byrnes via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Feb  5 16:50:53 PST 2024
    
    
  
================
@@ -1213,7 +1213,12 @@ Value *AMDGPUCodeGenPrepareImpl::expandDivRem24(IRBuilder<> &Builder,
                                                 BinaryOperator &I, Value *Num,
                                                 Value *Den, bool IsDiv,
                                                 bool IsSigned) const {
-  int DivBits = getDivNumBits(I, Num, Den, 9, IsSigned);
+  unsigned SSBits = Num->getType()->getScalarSizeInBits();
+  // If Num bits <= 24, assume 0 signbits.
+  unsigned AtLeast = (SSBits <= 24) ? 0 : (SSBits - 24);
+  if (IsSigned)
+    AtLeast++;
----------------
jrbyrnes wrote:
Should we be incrementing AtLeast for SSBits < 24?
https://github.com/llvm/llvm-project/pull/80622
    
    
More information about the llvm-commits
mailing list