This is an archive of the discontinued LLVM Phabricator instance.

[TypePromotion] Extend TypePromotion::isSafeWrap
ClosedPublic

Authored by dmgreen on Nov 11 2021, 7:27 AM.

Details

Summary

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.

Diff Detail

Event Timeline

dmgreen created this revision.Nov 11 2021, 7:27 AM
dmgreen requested review of this revision.Nov 11 2021, 7:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 11 2021, 7:27 AM
samparker accepted this revision.Nov 12 2021, 1:23 AM

Good bit of brain exercise for the morning... Nice addition and cleanup too, thanks. Just a couple of function renaming requests from me.

llvm/test/CodeGen/AArch64/typepromotion-overflow.ll
175–176

Good to change the function name before committing, same for the other altered test.

llvm/test/Transforms/TypePromotion/ARM/wrapping.ll
103

And in this file too :)

This revision is now accepted and ready to land.Nov 12 2021, 1:23 AM
This revision was automatically updated to reflect the committed changes.