[Mlir-commits] [llvm] [mlir] MathExtras: avoid unnecessarily widening types (PR #95426)

Matt Arsenault llvmlistbot at llvm.org
Thu Jun 13 15:04:59 PDT 2024


================
@@ -986,7 +986,9 @@ unsigned getMaxFlatWorkGroupSize(const MCSubtargetInfo *STI) {
 
 unsigned getWavesPerWorkGroup(const MCSubtargetInfo *STI,
                               unsigned FlatWorkGroupSize) {
-  return divideCeil(FlatWorkGroupSize, getWavefrontSize(STI));
+  // divideCeil will overflow, unless FlatWorkGroupSize is cast.
+  return divideCeil(static_cast<uint64_t>(FlatWorkGroupSize),
+                    getWavefrontSize(STI));
----------------
arsenm wrote:

There's no way this should require 64-bit 

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


More information about the Mlir-commits mailing list