This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] New 64 bit div/rem expansion
ClosedPublic

Authored by rampitec on Oct 5 2017, 4:23 PM.

Details

Summary

Old expansion was 20 VGPRs, 78 SGPRs and ~380 instructions.
This expansion is 11 VGPRs, 12 SGPRs and ~120 instructions.

Passes OpenCL conformance test_integer_ops quick_[u]long_math

Diff Detail

Repository
rL LLVM

Event Timeline

rampitec created this revision.Oct 5 2017, 4:23 PM
b-sumner added inline comments.Oct 5 2017, 4:55 PM
lib/Target/AMDGPU/AMDGPUISelLowering.cpp
1623 ↗(On Diff #117932)

It wouldn't hurt to have more comments expressing the algorithm in a C-like style.

rampitec added inline comments.Oct 5 2017, 7:05 PM
lib/Target/AMDGPU/AMDGPUISelLowering.cpp
1623 ↗(On Diff #117932)

This is more like todo: we can insert this "if" here and split the BB. That is questionable though if it is profitable in the divergent control flow and not really easy during the lowering. It is substituted by the cndmask after endif comments. Anyway, comment is left if later we decide to use if/then here.

javed.absar added inline comments.
lib/Target/AMDGPU/AMDGPUISelLowering.cpp
1511 ↗(On Diff #117932)

Maybe a good idea to put a contextual message along with your assert :
e.g. assert(VT == EVT:i64 && "LowerUDIVREM64 expects a i64")
or something like that.

b-sumner accepted this revision.Oct 6 2017, 7:19 AM

Looks good to me.

This revision is now accepted and ready to land.Oct 6 2017, 7:19 AM

Is this a port of what SC emits? I thought it emitted control flow for this.

Is this a port of what SC emits? I thought it emitted control flow for this.

Yes, I have replaced control flow with cndmasks at the end of blocks. Thus if/endif comments.

rampitec updated this revision to Diff 118029.Oct 6 2017, 10:08 AM
rampitec marked an inline comment as done.

Added message to assert.

arsenm added inline comments.Oct 6 2017, 10:08 AM
lib/Target/AMDGPU/AMDGPUISelLowering.cpp
1623 ↗(On Diff #117932)

This is why D18072 was going to be an IR expansion of this. The comment should be more descriptive that it may be beneficial to expand this with control flow outside of the DAG to allow skipping over this portion.

rampitec updated this revision to Diff 118031.Oct 6 2017, 10:13 AM
rampitec marked an inline comment as done.

Added comment.

This revision was automatically updated to reflect the committed changes.