[PATCH] D125653: [TypePromotion] Fix another case for sext vs zext in promoted constant.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 19 21:15:57 PDT 2022


craig.topper added a comment.

In D125653#3524325 <https://reviews.llvm.org/D125653#3524325>, @dmgreen wrote:

> If I haven't got this wrong, this says we could just always be zexting the constant from a sub:
> https://alive2.llvm.org/ce/z/kTAyt2
> https://alive2.llvm.org/ce/z/a6HHq4
> That sounds like it would make simpler constants too, although I'm not sure there are any tests that show it.
>
> What do you think? Otherwise I believe this is correct.

Since the pre-condition is -C1 <=s 0, then for all values of C1 <https://reviews.llvm.org/C1> except 0x80, the sign bit of C1 <https://reviews.llvm.org/C1> is 0. And the 0x80 case is the bug that requires zext. 0x80 can only occur for one of the two proofs since the first proof requires -C1 >s C2 which is never true for C1 <https://reviews.llvm.org/C1>==0x80. I think all this means that yes we could use zext for sub, but I don't think it will generate better constants.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125653/new/

https://reviews.llvm.org/D125653



More information about the llvm-commits mailing list