diff options
author | alexfh <alexfh@google.com> | 2024-03-19 20:15:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-19 12:15:30 -0700 |
commit | a6e231bb2a7924f4269e6735d29a54b2318cd16c (patch) | |
tree | da766626c80921ba657318e502458dc3482116f1 /llvm/lib | |
parent | 28c1279db3541bc7b246fd9da0da3da4e09f0eed (diff) | |
download | llvm-a6e231bb2a7924f4269e6735d29a54b2318cd16c.zip llvm-a6e231bb2a7924f4269e6735d29a54b2318cd16c.tar.gz llvm-a6e231bb2a7924f4269e6735d29a54b2318cd16c.tar.bz2 |
Revert "[Float2Int] Resolve FIXME: Pick the smallest legal type that fits" (#85843)
Reverts llvm/llvm-project#79158, which causes a miscompile. See
https://github.com/llvm/llvm-project/pull/79158#issuecomment-2007842032
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Scalar/Float2Int.cpp | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/llvm/lib/Transforms/Scalar/Float2Int.cpp b/llvm/lib/Transforms/Scalar/Float2Int.cpp index 6ad4be169..ccca8bc 100644 --- a/llvm/lib/Transforms/Scalar/Float2Int.cpp +++ b/llvm/lib/Transforms/Scalar/Float2Int.cpp @@ -311,7 +311,7 @@ void Float2IntPass::walkForwards() { } // If there is a valid transform to be done, do it. -bool Float2IntPass::validateAndTransform(const DataLayout &DL) { +bool Float2IntPass::validateAndTransform() { bool MadeChange = false; // Iterate over every disjoint partition of the def-use graph. @@ -376,24 +376,16 @@ bool Float2IntPass::validateAndTransform(const DataLayout &DL) { LLVM_DEBUG(dbgs() << "F2I: Value not guaranteed to be representable!\n"); continue; } - - // 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) { - Ty = Type::getInt32Ty(*Ctx); - } else if (MinBW <= 64) { - Ty = Type::getInt64Ty(*Ctx); - } else { - LLVM_DEBUG(dbgs() << "F2I: Value requires more than bits to represent " - "than the target supports!\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); + for (auto MI = ECs.member_begin(It), ME = ECs.member_end(); MI != ME; ++MI) convert(*MI, Ty); @@ -499,8 +491,7 @@ bool Float2IntPass::runImpl(Function &F, const DominatorTree &DT) { walkBackwards(); walkForwards(); - const DataLayout &DL = F.getParent()->getDataLayout(); - bool Modified = validateAndTransform(DL); + bool Modified = validateAndTransform(); if (Modified) cleanup(); return Modified; |