Hello folks!<div><br></div><div>This is an early patch, it still has some rough edges. In particular, I want to clean up the body of the loop which looks for operations to simplify in the function body, but I wanted to start showing people where I'm going here and get any feedback sooner rather than later.</div>

<div><br></div><div>The motivation for these heroics (and I recognize that these are heroics) is to handle cases like:</div><div><br></div><div>template <typename IteratorT></div><div>foo my_algorithm(IteratorT first, IteratorT last) {</div>

<div>  if (std::distance(first, last) < 42) {</div><div>    // Algorithm A</div><div>  } else {</div><div>    // Algorithm B</div><div>  }</div><div>}</div><div><br></div><div>Without this patch, the inline cost will be assumed to be the total size of the function, even when we call it like so:</div>

<div><br></div><div>void test(int *ptr) {</div><div>  foo bar = my_algorithm(ptr, ptr + 13);</div><div>}</div><div><br></div><div>Here, the arguments are a known constant offset, and yet we won't see that, or see that only one half of the branch in my_algorithm is going to survive. This causes missed optimizations every time we use an STL algorithm on a fixed buffer (usually a stack object).</div>

<div><br></div><div>The patch tries to track these correlated pointer values, and detect when they're used in a way that will simplify. Initial testing shows that it works, but I haven't yet reduced my big test cases into nice small feature tests for the test suite. Clearly, that has to happen before check-in.</div>

<div><br></div><div><br></div><div>Let me know your thoughts! I'll post a new patch as I clean it up, and I'll also post numbers as I have them on the impact this gives.</div>