[TypePromotion] Fix sext vs zext in promoted constant
authorDavid Green <david.green@arm.com>
Wed, 11 May 2022 09:47:44 +0000 (10:47 +0100)
committerDavid Green <david.green@arm.com>
Wed, 11 May 2022 09:47:44 +0000 (10:47 +0100)
commit5feeceddb2b5422dcb555b6d601e35a2d7840707
treef32d5e50afcae3043f983d624c77278333db81a8
parentc1d48b35d88a7eb497c9f9851bfab868228c52dd
[TypePromotion] Fix sext vs zext in promoted constant

As pointed out in #55342, given non-canonical IR with multiple
constants, we check the second operand in isSafeWrap, but can promote
both with sext. Fix that as suggested by @craig.topper by ensuring we
only extend the second constant if multiple are present.

Fixes #55342

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