Page MenuHomePhabricator

[SCEV] Compute exit count for simple floating point IVs
Needs ReviewPublic

Authored by reames on Oct 10 2019, 5:32 PM.

Details

Summary

This patch adds the plumbing for computing exit counts for loops with floating point IVs. The logic is generally pretty simple (deliberately). The basic reasoning is that if we have an IV with integer values represented as floats, then we can compute the exit counts "as-if" they were ints.

The motivation here is to eventually subsume the logic inside IndVarSimplify::handleFloatingPointIV, and restructure that one to simply perform the transform. By doing so, we handle a much broader class of floating point IV loops than we do today.

To be fair, the actual motivation behind all of this is to break a toy microbenchmark. This is not something seen in real code.

Diff Detail

Event Timeline

reames created this revision.Oct 10 2019, 5:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 10 2019, 5:32 PM
fhahn added a subscriber: fhahn.Oct 11 2019, 3:52 AM
nikic added a comment.Oct 12 2019, 3:34 AM

I'm wondering if we can't extend Float2Int to convert these to operations on integers. I'm assuming it currently doesn't due to a FIXME: Handle select and phi nodes.

I'm wondering if we can't extend Float2Int to convert these to operations on integers. I'm assuming it currently doesn't due to a FIXME: Handle select and phi nodes.

I'd really rather not continue extending a dedicated transform pass specifically for floats when we have a generic framework it fits naturally within which drives a number of existing optimizations. That feels like a much cleaner factoring.

Or to say it differently, we have a generic framework for reasoning about phis which happen to be induction variables. That's SCEV.