[InstCombine] Look through truncate to fold icmp with intrinsics
authorchenglin.bi <chenglin.bi@linaro.org>
Fri, 10 Feb 2023 02:31:44 +0000 (10:31 +0800)
committerchenglin.bi <chenglin.bi@linaro.org>
Fri, 10 Feb 2023 02:33:07 +0000 (10:33 +0800)
commit6f149a17d4b1a254dd41a3b910021481c564a691
treece1ad9e423b25c3b76e6f303dcfde3ae83cc7d0c
parentde17c665e3f995c7f5a0e453461ce3a1b8aec196
[InstCombine] Look through truncate to fold icmp with intrinsics

The output of intrinsic functions like ctpop, cttz, ctlz have limited range from 0 to bitwidth. So if the truncate destination type can hold the source bitwidth size, we can just ignore the truncate and use the truncate src to do combination.

Alive2 proofs:
https://alive2.llvm.org/ce/z/9D_-qP

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D143368
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
llvm/test/Transforms/InstCombine/cmp-intrinsic.ll