[InstCombine] fold icmp of zext bool based on limited range
authorSanjay Patel <spatel@rotateright.com>
Mon, 23 May 2022 13:26:43 +0000 (09:26 -0400)
committerSanjay Patel <spatel@rotateright.com>
Mon, 23 May 2022 13:59:21 +0000 (09:59 -0400)
commit1ebad988b1106e5cb35ea76813a4d3f66070b8f0
treee8e6d5257d666d6a05c4e1d4f313d42b411aef6a
parent6793c63e885179c8b7f7c90117fb1bc948e7c02c
[InstCombine] fold icmp of zext bool based on limited range

X <u (zext i1 Y) --> (X == 0) && Y

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

This is a generalization of 4069cccf3b4ff4a based on the post-commit suggestion.
This also adds the i1 type check and tests that were missing from the earlier
attempt; that commit caused several bot fails and was reverted.

Differential Revision: https://reviews.llvm.org/D126171
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/icmp-range.ll