[TypePromotion] Fix another case for sext vs zext in promoted constant.
authorCraig Topper <craig.topper@sifive.com>
Fri, 20 May 2022 04:19:12 +0000 (21:19 -0700)
committerCraig Topper <craig.topper@sifive.com>
Fri, 20 May 2022 16:30:07 +0000 (09:30 -0700)
commit8d3894f67ebf475e4393abeab91736bf534ff8f8
treeb65e5c345ecc700584855815006846a9676bbec6
parent1f12718ccfd660f01ac0e444d4632cf8ce6b98e2
[TypePromotion] Fix another case for sext vs zext in promoted constant.

If the SafeWrap operation is a subtract, we negated the constant
to treat the subtract as an addition. The sext was based on the
operation being addition. So we really need to do (neg (sext (neg C)))
when promoting the constant. This is equivalent to (sext C) for
every value of C except the min signed value. For min signed value
we need to do (zext C) instead.

Fixes PR55490.

Differential Revision: https://reviews.llvm.org/D125653
llvm/lib/CodeGen/TypePromotion.cpp
llvm/test/Transforms/TypePromotion/ARM/icmps.ll