[PATCH] D125774: [InstCombine] fold float trunc into exact itofp for small constants

Allen zhong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 17 06:29:28 PDT 2022


Allen created this revision.
Allen added reviewers: spatel, efriedma, sdesmalen.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Allen requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

In general, we can't combine a floating-point extension cast with a conversion from integer.
But when we known the value iN is small, and within the range of 1<<24, then we can combine
similar to type double done in D79116 <https://reviews.llvm.org/D79116>, ie:
sext (fptosi (sitofp iN to float)) to i64 --> sext iN to i64

Fixes https://github.com/llvm/llvm-project/issues/55505.


https://reviews.llvm.org/D125774

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
  llvm/test/Transforms/InstCombine/fptrunc.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125774.430021.patch
Type: text/x-patch
Size: 5086 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220517/4e6f7197/attachment.bin>


More information about the llvm-commits mailing list