[PATCH] D95690: [LoopVectorize] improve IR fast-math-flags propagation in reductions

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 1 05:01:09 PST 2021


spatel added a comment.

In D95690#2532922 <https://reviews.llvm.org/D95690#2532922>, @grandinj wrote:

> Is there some way to do symbolic execution of IR that results in some kind of "output state" of FMF at the end of a block of IR? 
> If such a thing existed, then running it on the IR before and after a pass, and comparing the state of FMF at the end of that chunk of IR, would validate if the pass was correctly propagating FMF.

The closest that I know of is Alive2:
https://alive2.llvm.org/ce/z/2oNg9N
In that example, I added a `nnan` clause to the fadd, and Alive shows us how it is invalid (we produce poison in the transformed case where the original did not).
Alive2 is currently limited in its understanding of FMF, and I'm not sure if it can ever provide full FP analysis.

If we just want a weak/cheap solution, we could add a step to IR verification that checks if any FMF exist in the output that were not present in the input. For example, in the loop vectorizer tests shown here, we are obviously adding flags that are not anywhere in the original code. The verifier check would have to account for FP ops that have special semantics (eg, the intrinsic `maxnum` doesn't exactly specify how the sign of zero affects the result), and it would also need to account for FP function attributes since we still partly rely on those.

It's beyond the scope of anything I'm trying to do in this patch, but it's an interesting idea - file a bugzilla and/or llvm-dev note to get more attention?


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

https://reviews.llvm.org/D95690



More information about the llvm-commits mailing list