[InstCombine] do not exclude min/max from icmp with casted operand fold
authorSanjay Patel <spatel@rotateright.com>
Mon, 30 Mar 2020 19:49:27 +0000 (15:49 -0400)
committerSanjay Patel <spatel@rotateright.com>
Mon, 30 Mar 2020 20:10:51 +0000 (16:10 -0400)
commitf2fbdf76d8d07f6a0fbd97825cbc533660d64a37
tree9051fd8d7a945fb5093f7718d7793b1cbe2e2b74
parentde77d2312751514ce9fbf9b0bf11cbe93cd486f9
[InstCombine] do not exclude min/max from icmp with casted operand fold

InstCombine has a mess of logic that tries to preserve min/max patterns,
but AFAICT, this one is not necessary because we can always narrow the
corresponding select in this sequence to match the narrow compare.

The biggest danger for this patch is inducing infinite looping or
assert from exceeding max iterations. If any bots hit that in the
vicinity of this commit, this is the likely patch to blame.
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/adjust-for-minmax.ll
llvm/test/Transforms/InstCombine/select_meta.ll