RFR: 8324655: Identify integer minimum and maximum patterns created with if statements [v3]

Jasmine Karthikeyan jkarthikeyan at openjdk.org
Tue Mar 5 04:10:47 UTC 2024


On Mon, 4 Mar 2024 08:59:46 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

> You mean you would be matching for a `Cmp -> CMove` node pattern that is equivalent for `Min/Max`, rather than matching a `Cmp -> If -> Phi` pattern?

Yeah, I was thinking it might be better to let the CMove transform happen first, since the conditions guarding both transforms are aiming to do the same thing in essence. My thought was that if the regression in your `testCostDifference` was fixed, it would be better to not have to do that fix in two different locations, since it impacts `is_minmax` as well.

> BTW, I watched a fascinating talk about branch-predictors / branchless code yesterday

Thank you for linking this talk, it was really insightful! I also wonder if it would be possible to capture branch execution patterns somehow, to drive branch flattening optimizations. I figure it could be possible to keep track of the sequence of a branch's history of execution, and then compute some "entropy" value from that sequence to determine if there's a pattern, or if it's random and likely to be mispredicted. However, implementing that in practice sounds pretty difficult.

@eme64 I've pushed a commit that fixes the benchmarks and sets the loop iteration count to 10_000. Could you check if this lets it vectorize on your machine? Thanks!

-------------

PR Comment: https://git.openjdk.org/jdk/pull/17574#issuecomment-1977932187


More information about the hotspot-compiler-dev mailing list