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

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 5 08:35:25 PDT 2023


foad added inline comments.


================
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.
----------------
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.


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

https://reviews.llvm.org/D154496



More information about the llvm-commits mailing list