This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] BL/BH are considered aliases in regreassign
ClosedPublic

Authored by hzq on Jul 12 2023, 9:31 AM.

Details

Summary

The relationship of X86 registers is shown in the diagram. BL and BH do
not have a direct alias relationship. However, if the BH register cannot be
swapped, then the BX/EBX/RBX registers cannot be swapped as well, which
means that BL register also cannot be swapped. Therefore, in the presence
of BX/EBX/RBX registers, BL and BH have an alias relationship.

┌────────────────┐
│  RBX           │
├────┬───────────┤
│    │ EBX       │
├────┴──┬────────┤
│       │   BX   │
├───────┼───┬────┤
│       │BH │BL  │
└───────┴───┴────┘

Diff Detail

Event Timeline

hzq created this revision.Jul 12 2023, 9:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2023, 9:31 AM
hzq requested review of this revision.Jul 12 2023, 9:31 AM
hzq updated this revision to Diff 546868.Aug 3 2023, 7:45 AM
hzq retitled this revision from [BOLT] Fix bug for reg-reassign to [BOLT] BL/BH are considered aliases in regreassign.
hzq edited the summary of this revision. (Show Details)

Update.

hzq updated this revision to Diff 551818.Aug 20 2023, 4:59 AM

Updating Context and Test Cases.

rafauler added inline comments.Aug 22 2023, 2:09 PM
bolt/lib/Passes/RegReAssign.cpp
149

move this comment next to the first call to BC.MIB->getAliasSized(Reg, 1), otherwise it is a bit confusing what it is referring to

390

I'm a bit confused, maybe you mean "To prevent the high" instead of "To prevent the low" here?

bolt/test/X86/reg-reassign-no-swap-bl.s
10 ↗(On Diff #551818)

Drop --debug-only as it is not being used.

11 ↗(On Diff #551818)

If this test is running the output of BOLT, then it should go to bolt/test/runtime/X86

hzq updated this revision to Diff 552778.Aug 23 2023, 10:07 AM
rafauler accepted this revision.Aug 23 2023, 11:51 AM

Thanks! LGTM

This revision is now accepted and ready to land.Aug 23 2023, 11:51 AM
hzq updated this revision to Diff 553157.Aug 24 2023, 9:17 AM
hzq requested review of this revision.Aug 24 2023, 9:19 AM

@rafauler, I'm sorry I didn't run the complete test cases earlier. Could you please help review it again?

bolt/lib/Passes/RegReAssign.cpp
390

Yes, you are right, thanks.

I'm not sure why runtime/X86/reg-reassign-swap-cold.s is failing. I can't repro the failure. I would suggest submitting your changes on another revision using arc diff --draft, so it is not published, but you can still run the tests to see if they pass, and they debug it from there -- perhaps by removing modifications you did to see if the test pass, getting hints on what is wrong.

hzq added a comment.Aug 25 2023, 9:32 AM

I'm not sure why runtime/X86/reg-reassign-swap-cold.s is failing. I can't repro the failure. I would suggest submitting your changes on another revision using arc diff --draft, so it is not published, but you can still run the tests to see if they pass, and they debug it from there -- perhaps by removing modifications you did to see if the test pass, getting hints on what is wrong.

The current modifications appear to have resulted in all test cases passing.

I'm not sure why runtime/X86/reg-reassign-swap-cold.s is failing. I can't repro the failure. I would suggest submitting your changes on another revision using arc diff --draft, so it is not published, but you can still run the tests to see if they pass, and they debug it from there -- perhaps by removing modifications you did to see if the test pass, getting hints on what is wrong.

The current modifications appear to have resulted in all test cases passing.

LGTM

hzq accepted this revision.Aug 28 2023, 7:15 AM
This revision is now accepted and ready to land.Aug 28 2023, 7:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 28 2023, 8:04 AM