[PATCH] D113678: [TypePromotion] Extend TypePromotion::isSafeWrap

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 11 07:27:35 PST 2021


dmgreen created this revision.
dmgreen added reviewers: SjoerdMeijer, samparker, efriedma, craig.topper, avieira.
Herald added a subscriber: hiraditya.
dmgreen requested review of this revision.
Herald added a project: LLVM.

This modifies the preconditions of TypePromotion's isSafeWrap method, to allow it to work from all constants from the ICmp. Using the code:

  %a = add %x, C1
  %c = icmp ult %a, C2

According to Alive, we can prove that is equivalent to `icmp ult (add zext(%x), sext(C1)), zext(C2)` given `C1 <=s 0 and C1 >s C2`.
https://alive2.llvm.org/ce/z/CECYZB
And can prove `icmp ult (add zext(%x), sext(C1)), sext(C2)` given `C1 <=s 0 and C1 <=s C2`.
https://alive2.llvm.org/ce/z/KKgyeL

The PrepareWrappingAdds method was removed, and the constants are now altered to sext or zext directly as required by the above methods.


https://reviews.llvm.org/D113678

Files:
  llvm/lib/CodeGen/TypePromotion.cpp
  llvm/test/CodeGen/AArch64/and-mask-removal.ll
  llvm/test/CodeGen/AArch64/typepromotion-overflow.ll
  llvm/test/Transforms/TypePromotion/ARM/casts.ll
  llvm/test/Transforms/TypePromotion/ARM/clear-structures.ll
  llvm/test/Transforms/TypePromotion/ARM/icmps.ll
  llvm/test/Transforms/TypePromotion/ARM/wrapping.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113678.386511.patch
Type: text/x-patch
Size: 15519 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211111/9dcfc6c7/attachment.bin>


More information about the llvm-commits mailing list