[InstCombine] try to fold icmp with mismatched extended operands
authorSanjay Patel <spatel@rotateright.com>
Tue, 26 Apr 2022 18:22:16 +0000 (14:22 -0400)
committerSanjay Patel <spatel@rotateright.com>
Tue, 26 Apr 2022 18:26:36 +0000 (14:26 -0400)
commit903aa5e0f80efd413624a59e37c6ace6cd3cf5cd
treee91b0b018fc4afcdc7494307af94f13976b51073
parent6a9bbd9f20dcd700e28738788bb63a160c6c088c
[InstCombine] try to fold icmp with mismatched extended operands

If a value is known to be non-negative and zexted,
that's the same thing as sexted.

So for the purpose of looking past the casts with
an icmp, treat it as if it was a sext:
https://alive2.llvm.org/ce/z/_BDsGV

This is necessary, but not enough to solve the
motivating problem:
https://github.com/llvm/llvm-project/issues/55013

Differential Revision: https://reviews.llvm.org/D124419
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
llvm/test/Transforms/InstCombine/icmp-ext-ext.ll