RKSimon added a comment. I think its almost there now, my only concern is that we're not discriminating between signed/unsigned in getMinMaxReductionCost calls - e.g. SSE is very inconsistent with support for these. https://reviews.llvm.org/D27846