[PATCH] D37762: [InstCombine] Remove single use restriction from InstCombine's explicit sinking code.

Daniel Berlin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 13 18:00:53 PDT 2017


dberlin added a comment.

The assembly is clearly worse, the IR is clearly better.
The IR has removed all computation except a mask of the input.
(Note, in the dump i gave, it has not run DCE, so there's a bunch of dead phis).
In essence, it has turned the entire function into a nested switch statement based on the bar & x values.

GCC then does not do a good job of doing something with that in the backend.

This could be codegened precisely the way a switch could be (IE lookup table, binary tree, etc).
It can use as many or as few registers as you like.
In fact, in this form, it's also ripe for vectorization.
You could load the constants into AVX512 registers (it should take 2), the bar & values into another, and use the & to reduce and select the right constant from the vector registers.

So, i'm going to say "yes, the IR is better, it could probably use canonicalization or something to take it out of the phi form and put it into a canonical nested switch".


https://reviews.llvm.org/D37762





More information about the llvm-commits mailing list