[llvm] [Transforms] Resolve FIXME: Pick the smallest legal type that fits (PR #79158)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 12 14:26:06 PDT 2024
================
@@ -376,15 +376,23 @@ 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");
- continue;
- }
- // OK, R is known to be representable. Now pick a type for it.
- // FIXME: Pick the smallest legal type that will fit.
- Type *Ty = (MinBW > 32) ? Type::getInt64Ty(*Ctx) : Type::getInt32Ty(*Ctx);
+ // OK, R is known to be representable.
+ // Pick the smallest legal type that will fit.
+ Type *Ty = DL.getSmallestLegalIntType(*Ctx, MinBW);
+ if (!Ty) {
+ // Every supported target supports 64-bit and 32-bit integers,
+ // so fallback to a 32 or 64-bit integer if the value fits.
+ if (MinBW <= 32)
----------------
aeubanks wrote:
nit: braces should be consistently applied, so add braces
https://github.com/llvm/llvm-project/pull/79158
More information about the llvm-commits
mailing list