[PATCH] D128591: Transforms: Relax restrictions on pow(x, y) expansion

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 4 12:22:27 PDT 2022


spatel added a comment.

In D128591#3628267 <https://reviews.llvm.org/D128591#3628267>, @pawosm01 wrote:

> @spatel we have discussed your comment here, and my understanding is that you're not opposing to the proposed change as such, I guess what you wanted to know is how we ended up with proposed set of flags. At the time of our experiments, we were focused on trying to restrict certain optimizations to the lowest possible set of fast math flags. We were comparing with what Intel compiler can do by default at `-O3` as it is more relaxed than clang, so we wanted to find a route to getting similar effect.
>
> As such I'm finding the test case presented here fitting to the nature of our experiment and I don't see anything missing. Maybe it is quite academic and many may not find a huge benefit of that; in the end, it is sufficient to use `-funsafe-math-optimizations` flag in order to relax restrictions.

Thanks for the background info. FP optimization flags are not precisely specified, so there will be mismatches between clang vs. icc vs. gcc. If you want to allow this with `-fassociative-math` + `-ffinite-math-only`, then we'd need to adjust something in the front-end because `reassoc` is not applied to the pow call:
https://godbolt.org/z/obeenobfq

I didn't realize we had the TLI hook to expand powi already, so I agree with @RKSimon (and there's a TODO comment in this code about removing the expansion here in IR) - we should convert to powi here and leave the expansion under target control in the backend. Maybe this already works if you just delete the expansion in this file?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128591



More information about the llvm-commits mailing list