[PATCH] D154496: InstCombine: Fold ldexp(ldexp(x, a), b) -> ldexp(x, a + b)

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 7 05:15:30 PDT 2023


arsenm closed this revision.
arsenm added a comment.

4f9aad964f4a8fb364f8069eca1825865ca85b80 <https://reviews.llvm.org/rG4f9aad964f4a8fb364f8069eca1825865ca85b80>



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:2381-2383
+    // It's also safe to fold if we know both exponents have the same sign since
+    // it would just double down on the overflow/underflow which would occur
+    // anyway.
----------------
foad wrote:
> arsenm wrote:
> > foad wrote:
> > > arsenm wrote:
> > > > foad wrote:
> > > > > Additionally it would be safe if both exponents are known to be <= 0, but I guess we don't have a helper function for that.
> > > > Right we totally lack FP range tracking
> > > I just mean for the integer exponents, you're checking if they're both < 0, but that could be relaxed to both <= 0.
> > This checks that they are both positive or both negative so I’m not sure what you mean 
> Your code optimizes if they are both >= 0 or both < 0.
> You could optimize if they are both >= 0 or both <= 0. This might optimize more cases.
added todo


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154496/new/

https://reviews.llvm.org/D154496



More information about the llvm-commits mailing list