[PATCH] D127801: [InstCombine] convert mask and shift of power-of-2 to cmp+select

chenglin.bi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 15 09:37:08 PDT 2022


bcl5980 added a comment.

Actually even if the instruction number are the same, we still prefer shift+and because cmp port is less than shift for most modern CPU I think.

> Do you have an example for a target where the code looks worse with the cmp+select IR?

And I try to create 2 cases: https://alive2.llvm.org/ce/z/exvD7T

I agree that they have very little difference generally.
I also agree that we shouldn't consider too much CPU micro arch for a IR transform.
Maybe we can add metadata MD_range for x to keep the information then backend can get enough information to invert the transform.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127801/new/

https://reviews.llvm.org/D127801



More information about the llvm-commits mailing list