[InstCombine] canonicalize cmp+select as smin/smax
authorSanjay Patel <spatel@rotateright.com>
Sun, 12 Feb 2023 11:56:43 +0000 (06:56 -0500)
committerSanjay Patel <spatel@rotateright.com>
Sun, 12 Feb 2023 12:54:43 +0000 (07:54 -0500)
commitf48f178717927e77c42ef17de42688b8a60733e3
tree14a69deb7019c79d489082674938b98b21bdd4b7
parent14411adc3dced93c536628ee985f5eea2ffe73ab
[InstCombine] canonicalize cmp+select as smin/smax

(V == SMIN) ? SMIN+1 : V --> smax(V, SMIN+1)
(V == SMAX) ? SMAX-1 : V --> smin(V, SMAX-1)

https://alive2.llvm.org/ce/z/d5bqjy

Follow-up for the unsigned variants added with:
86b4d8645fc1b866

issue #60374
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/select.ll