[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:39:50 PST 2024
================
@@ -382,9 +382,18 @@ bool Float2IntPass::validateAndTransform() {
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;
+ if (MinBW <= 8) {
+ Ty = Type::getInt8Ty(*Ctx);
+ } else if (MinBW <= 16) {
+ Ty = Type::getInt16Ty(*Ctx);
+ } else if (MinBW <= 32) {
+ Ty = Type::getInt32Ty(*Ctx);
+ } else {
+ Ty = Type::getInt64Ty(*Ctx);
+ }
----------------
nikic wrote:
You'll have to adjust the tests to specify a suitable data layout, see https://llvm.org/docs/LangRef.html#data-layout.
https://github.com/llvm/llvm-project/pull/79158
More information about the llvm-commits
mailing list