This is an archive of the discontinued LLVM Phabricator instance.

Allow unsigned comparisons
ClosedPublic

Authored by jdoerfert on Apr 26 2016, 2:49 AM.

Details

Summary
We will now optimistically assume that the result of an unsigned comparison
is the same as the result of the same comparison interpreted as signed. To
this end we will simply assume that both operands are non-negative.

Diff Detail

Event Timeline

jdoerfert updated this revision to Diff 54976.Apr 26 2016, 2:49 AM
jdoerfert retitled this revision from to Allow unsigned comparisons.
jdoerfert added reviewers: grosser, Meinersbur.
jdoerfert updated this object.
jdoerfert added a subscriber: Restricted Project.
Meinersbur accepted this revision.Apr 26 2016, 3:51 AM
Meinersbur edited edge metadata.
Meinersbur added inline comments.
lib/Analysis/ScopInfo.cpp
1323–1326

I assume that RTCs checks will always be signed therefor this will check whether the MSB is not 1. Could you add a comment for that?

test/ScopInfo/simple_loop_unsigned.ll
3–7

This has no unsigned comparison. Can you make it represent the IR below? Eg.

for (i = 0; (uint64_t)i < (uint64_t)N; ++i)

%i is of type i64, so I suggest to declare i as int64_t

13

Why is this significant for the test case?

test/ScopInfo/simple_loop_unsigned_2.ll
36

Since i is unsigned, why does it have a nsw flag?

This revision is now accepted and ready to land.Apr 26 2016, 3:51 AM
jdoerfert added inline comments.Apr 26 2016, 4:08 AM
lib/Analysis/ScopInfo.cpp
1323–1326

Will do.

test/ScopInfo/simple_loop_unsigned.ll
3–7

Ok.

13

Idk. Most of the check lines are not. Is this a problem now?

test/ScopInfo/simple_loop_unsigned_2.ll
36

that wasn't me (I think). Is it really important if it has this flag or not?

Meinersbur added inline comments.Apr 26 2016, 4:27 AM
test/ScopInfo/simple_loop_unsigned.ll
13

Not a problem, but makes it harder to understand what's the point of the test.

I could understand why checking the Statement because of its domain, but I don't know why checking the accessed array and its size should be relevant.

test/ScopInfo/simple_loop_unsigned_2.ll
36

This is a brand new test case, so who else could have added it?

The problem I see is that the commented C-code does not accurately represent the IR, hence does a disfavor when trying to understand the code. If you do not intend to keep the C-representation in-sync with the IR, you can just remove it.

jdoerfert added inline comments.Apr 26 2016, 4:52 AM
test/ScopInfo/simple_loop_unsigned.ll
13

Personally, I think this is overkill to argue about 3 trivial check lines of a test case that has 12 lines of IR. Anyway, you seem to care a lot about it and I will remove them.

test/ScopInfo/simple_loop_unsigned_2.ll
36

This is a brand new test case, so who else could have added it?

Clang? One of our preparation passes? Somebody else and I just copied an existing test case as a basis for this one?

The problem I see is that the commented C-code does not accurately represent the IR, hence does a disfavor when trying to understand the code. If you do not intend to keep the C-representation in-sync with the IR, you can just remove it.

Did you actually compile the code to IR? The nsw you seem to care about is always there. Regarding the mismatch of C and IR, your comment seems rather odd. We surely can just drop all the C code but I think it helps people to understand the structure of the test case, even though it is/cannot always represent the IR exactly. In general I think this is again a discussion that is out of place and if you care about it I would suggest you move it to the mailinglist.

jdoerfert closed this revision.Apr 28 2016, 7:41 AM

Commited in r267559.