Details

As we already discussed in llvm-dev forum http://lists.llvm.org/pipermail/llvm-dev/2016-May/099724.html
I'm working on FP SCEV analysis in order to enable loop vectorization with FP induction variables.
Trying to minimize the first patch, I implemented only simple cases. Once this patch is accepted, I continue to fill the gaps between integer and fp scevs.

I have made some minor comments inline, but I still stand by my earlier comment that we should do something like this as a last resort. As an initial step we should at least evaluate how far we can we can get on relevant workloads without teaching SCEV about floating point values at all.

I planned to use SCEVFAddExpr and SCEVFMulExpr to couple FP calculations, like it is done for integer operations.
for example: a + const1 + b + const2 = a + b + const3
or a * 0.0 = 0
If compiler supports FP reduction, it can support any FP simplification in this mode. I assume that fast-math should allow all these transformations.

Replacing x with fp_inc*N should require fast-math - and it's not clear to me what fast-math allows.
If this is correct with fast-math, we should be able to use this to get the backedge taken count - which would be a good reason for doing this in SCEV.

I don't know if this has been established before, but the vectorization tests use FP re-association, so fast-math is also required there.

Replacing x with fp_inc*N should require fast-math - and it's not clear to me what fast-math allows.
If this is correct with fast-math, we should be able to use this to get the backedge taken count - which would be a good reason for doing this in SCEV.

I don't know if this has been established before, but the vectorization tests use FP re-association, so fast-math is also required there.

If this is correct with fast-math, we should be able to use this to
get the backedge taken count - which would be a good reason for doing
this in SCEV.

Shouldn't SCEV today be able to compute the backedge taken count of
the above loop (since the controlling induction variable is
integral)?

Hi Sanjoy,

For that loop, yes, SCEV should be able to figure out the backedge taken count today.

But using that reasoning I think we should be able to get the backedge taken count for the following loop (again, I don't know if this is actually correct):

float i = 0.f;
for (; i < N; i+=fp_inc) {}

This was something previously raised by Michael on the llvm-dev thread.

Yes, it is possible with FP SCEV. I implemented fp-range and backedge taken count calculation, but I don't want to put everything in this patch.
Community should also decide about the flag, whether it will be "-ffast-math" or something else.