This is an archive of the discontinued LLVM Phabricator instance.

[SingleSource] Add Regression C tests for Large Divide.
Needs ReviewPublic

Authored by FreddyYe on Aug 29 2022, 6:37 AM.

Details

Summary

Event Timeline

FreddyYe created this revision.Aug 29 2022, 6:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 29 2022, 6:37 AM
FreddyYe requested review of this revision.Aug 29 2022, 6:37 AM
FreddyYe updated this revision to Diff 458106.Sep 6 2022, 12:04 AM

Extend the test and verify if pre-merge test is working.

FreddyYe edited the summary of this revision. (Show Details)
mgehre-amd added inline comments.Sep 6 2022, 3:30 AM
SingleSource/Regression/C/issue44994-1.c
43

I'm not sure I understand why we need to use a union and manually care about endianess.
I'm thinking that writing

unsigned _BitInt(256) a = 6;
unsigned _BitInt(256) b = 3;
unsigned _BitInt(256) q = a / b;
unsigned _BitInt(256) expected = 2;
if(q != expected)
  return 1;

should work fine on little and big endian machines.

Another thing to look out for is that those tests are not fully optimized to constants, and then there is no div left for the backend.
I guess we can either use -O0, or add some dependency on argc or similar.

FreddyYe added inline comments.Sep 6 2022, 10:44 PM
SingleSource/Regression/C/issue44994-1.c
43

I'm not sure I understand why we need to use a union and manually care about endianess.

It's only because I don't have a better way to initialize _BitInt(256) (e.g. 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF). Do you know a better way?

Another thing to look out for is that those tests are not fully optimized to constants.

According to the main_dump I generated with O2, I think the ExpandLargeDiv Pass is working. And I can find %div = udiv i256 %0, %1 in IR generated under O2.

mgehre-amd added inline comments.Sep 7 2022, 3:07 AM
SingleSource/Regression/C/issue44994-1.c
43

Maybe using the literal suffixes would work, see clang/test/Lexer/bitint-constants.c?