[llvm] [Transforms] Resolve FIXME: Pick the smallest legal type that fits (PR #79158)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 26 11:40:39 PST 2024


================
@@ -376,18 +376,17 @@ bool Float2IntPass::validateAndTransform() {
       LLVM_DEBUG(dbgs() << "F2I: Value not guaranteed to be representable!\n");
       continue;
     }
-    if (MinBW > 64) {
-      LLVM_DEBUG(
-          dbgs() << "F2I: Value requires more than 64 bits to represent!\n");
+
+    // OK, R is known to be representable.
+    // Pick the smallest legal type that will fit.
+    Type *Ty = DL.getSmallestLegalIntType(*Ctx, MinBW);
+    if (!Ty) {
----------------
nikic wrote:

It's okay to keep a 64-bit fallback here.

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


More information about the llvm-commits mailing list