This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Enabled v2.16 literals for VOP3P
ClosedPublic

Authored by rampitec on Apr 17 2018, 4:00 PM.

Details

Summary

Literal encoding needs op_sel_hi to select low 16 bit in this case.

Diff Detail

Event Timeline

rampitec created this revision.Apr 17 2018, 4:00 PM
kzhuravl accepted this revision.Apr 17 2018, 4:11 PM

LGTM, thanks.

This revision is now accepted and ready to land.Apr 17 2018, 4:11 PM
This revision was automatically updated to reflect the committed changes.

This looks simpler than I expect. Don' you need to change the operand classes of the packed instructions and check the 16-bit imm values?

arsenm added inline comments.Apr 18 2018, 1:34 AM
llvm/trunk/lib/Target/AMDGPU/SIFoldOperands.cpp
157–158 ↗(On Diff #142860)

Is this just handling the case where both halves are the same, or is this supposed to handle the mixed case where either high or low is 0?

This looks simpler than I expect. Don' you need to change the operand classes of the packed instructions and check the 16-bit imm values?

Yes, that is simpler than I expected too. I do not really need to check immediates. These are all VOP3P, so only inline literals are allowed. Those always fit.

llvm/trunk/lib/Target/AMDGPU/SIFoldOperands.cpp
157–158 ↗(On Diff #142860)

That is only for the case when high and low are equal. To get to this place it first must pass isOperandLegal check, which verifies both halfs are equal. We encode an inline constant and then use op_sel_hi to tell machine it must use low (and the only) part of the constant for high 16 bits too. Theoretically speaking we can also handle the case when hi 16 bit are zero, but that is not done now, it simply does not pass isInlinableLiteralV216() check. In most practical cases having zero in high part neglects the purpose of using packed instructions anyway.