This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] simplifyUnsignedRangeCheck(): '(a+b) </>= c &&/|| (a+b) ==/!= 0' if we known 'c' is 'a' or 'b' and is non-zero (PR43259)
Changes PlannedPublic

Authored by lebedev.ri on Sep 12 2019, 7:54 AM.

Details

Summary

I realize that these get increasingly boring with each patch,
but i'm running out of commit messages here :/

Alive proofs:
https://rise4fun.com/Alive/8Bq

https://bugs.llvm.org/show_bug.cgi?id=43259

Diff Detail

Event Timeline

lebedev.ri created this revision.Sep 12 2019, 7:54 AM
lebedev.ri retitled this revision from [InstSimplify] simplifyUnsignedRangeCheck(): '(a+b) </>= a/b &&/|| a/b ==/!= 0' if we known a or b is non-zero (PR43259) to [InstSimplify] simplifyUnsignedRangeCheck(): '(a+b) </>= c &&/|| (a+b) ==/!= 0' if we known 'c' is 'a' or 'b' and is non-zero (PR43259).

Fix fold: we need to know that the value we compared with in UnsignedICmp is non-zero, not either of the values in add.

spatel added inline comments.Sep 12 2019, 8:31 AM
llvm/lib/Analysis/InstructionSimplify.cpp
1413–1415

Comments don't match code.

lebedev.ri added inline comments.Sep 12 2019, 9:21 AM
llvm/lib/Analysis/InstructionSimplify.cpp
1413–1415

That's D67498

lebedev.ri added inline comments.Sep 12 2019, 9:25 AM
llvm/lib/Analysis/InstructionSimplify.cpp
1413–1415

Actually, i don't see it?
Comments being added by this patch, or D67498?

spatel added inline comments.Sep 12 2019, 9:55 AM
llvm/lib/Analysis/InstructionSimplify.cpp
1413–1415

Disregard - my comment applied to the earlier rev of the patch. Your update happened while I was looking at this.

llvm/test/Transforms/InstSimplify/result-of-add-of-negative-is-non-zero-and-no-underflow.ll
91–92

I thought you proved this test already?
https://rise4fun.com/Alive/WslQ

lebedev.ri planned changes to this revision.Sep 12 2019, 10:08 AM
lebedev.ri marked 4 inline comments as done.
lebedev.ri added inline comments.
llvm/test/Transforms/InstSimplify/result-of-add-of-negative-is-non-zero-and-no-underflow.ll
91–92

Uhm.
Looks like i'm losing the plot because all these patterns in these patches are so similar.
I should wait until three existing patches lang, and then deal with PR43259

Status of this patch?

xbolva00 resigned from this revision.Nov 15 2019, 4:40 PM