This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU : Fix mqsad_u32_u8 instruction incorrect data type.
ClosedPublic

Authored by wdng on Aug 18 2016, 5:37 PM.

Details

Summary
  1. Ouput and the third parameter should be v4i32.
  2. Add a 128 register class to hand the v4i32 case.

Diff Detail

Repository
rL LLVM

Event Timeline

wdng updated this revision to Diff 68638.Aug 18 2016, 5:37 PM
wdng retitled this revision from to AMDGPU : Fix mqsad_u32_u8 instruction incorrect data type..
wdng updated this object.
wdng added reviewers: arsenm, tstellarAMD, b-sumner.
wdng set the repository for this revision to rL LLVM.
arsenm edited edge metadata.Aug 18 2016, 5:41 PM

A lot more tests for the operand combinations are needed. There should be a test where every operand is a VGPR, SGPR, inline integer immediate, inline FP immediate, and non-inline constant

include/llvm/IR/Intrinsics.td
152 ↗(On Diff #68638)

You don't need this

lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
272–276 ↗(On Diff #68638)

You don't need SSrc128

lib/Target/AMDGPU/SIRegisterInfo.h
118–119 ↗(On Diff #68638)

Indentation. This probably isn't needed to be handled since it's starting out as isAllocatable = 0

wdng marked 2 inline comments as done.Aug 19 2016, 12:47 PM

A lot more tests for the operand combinations are needed.

Do you mean to use some combination like v2i64?

In D23700#521053, @wdng wrote:

A lot more tests for the operand combinations are needed.

Do you mean to use some combination like v2i64?

No, I mean the kinds of values that I listed

wdng added a comment.Aug 19 2016, 2:34 PM
In D23700#521053, @wdng wrote:

A lot more tests for the operand combinations are needed.

Do you mean to use some combination like v2i64?

No, I mean the kinds of values that I listed

Where are those values?

wdng updated this revision to Diff 68887.Aug 22 2016, 11:22 AM
wdng edited edge metadata.

Update LIT tests to make sure using operand as a VGPR, SGPR, inline integer immediate, inline FP immediate, and non-inline constant.

I think we need some execution tests to make sure the inline immediates and quad SGPR really work

test/CodeGen/AMDGPU/llvm.amdgcn.mqsad.u32.u8.ll
25–26 ↗(On Diff #68887)

This is broken. Storing the constant to undef is not useful. The high bits also need to be 0, and the constant vector should be the direct operand to the call

34–38 ↗(On Diff #68887)

None of these are inline fp immediates, and you don't want to do an fp cast to integer. You want the literal bit value for the FP immediate

46–56 ↗(On Diff #68887)

Nothing here is constraining the input to be a VGPR. The simplest way to get an SGPR is to use a kernel argument value. To get a VGPR you should use a load from addrspace(1)* or use inline asm

57 ↗(On Diff #68887)

Space before = (same for the other tests)

wdng updated this revision to Diff 68928.Aug 22 2016, 4:21 PM
wdng removed rL LLVM as the repository for this revision.
wdng marked 3 inline comments as done.

Update LIT tests.

wdng marked an inline comment as done.Aug 22 2016, 4:22 PM

New patch has fixed those issues.

arsenm added inline comments.Aug 22 2016, 6:24 PM
lib/Target/AMDGPU/SIRegisterInfo.td
348–350 ↗(On Diff #68928)

We don't need this since the operand is required to be VReg_128

wdng added inline comments.Aug 22 2016, 10:32 PM
lib/Target/AMDGPU/SIRegisterInfo.td
348–350 ↗(On Diff #68928)

Are you sure that we don' t need this? Since VS_128 is used a lot by other definitions...

wdng updated this revision to Diff 69395.Aug 26 2016, 10:21 AM

Remove 128-bit operand type definition and use VReg_128 directly.

arsenm added inline comments.Aug 26 2016, 10:40 AM
lib/Target/AMDGPU/SIInstrInfo.td
1123 ↗(On Diff #69395)

This should not be VCSrc_128, because an immediate is not allowed

wdng updated this revision to Diff 69410.Aug 26 2016, 11:15 AM

Use VSrc to replace VCSrc to take care of the immediate operand.

Because this is a new width operand, there should be some assembler tests for it

lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
276–278 ↗(On Diff #69410)

You should not need this

lib/Target/AMDGPU/SIRegisterInfo.td
403 ↗(On Diff #69410)

This should just be RegisterOperand

404 ↗(On Diff #69410)

I don't think you need the custom matcher

wdng updated this revision to Diff 69586.Aug 29 2016, 10:50 AM
wdng marked an inline comment as done.
  1. Changes based on Matt's comments.
  2. Add assembler tests.
arsenm added a comment.Sep 1 2016, 2:26 PM

The tests should be merged into the complete vop3 tests

wdng updated this revision to Diff 70225.Sep 2 2016, 1:46 PM

Merge assembler tests.

arsenm added inline comments.Sep 2 2016, 7:10 PM
test/MC/AMDGPU/vop3.s
1–2 ↗(On Diff #70225)

Only the NOSI one should be checking the stderr. The -mcpu=SI shouldalso be removed. This breaks all of the SICI check lines

wdng updated this revision to Diff 70439.Sep 6 2016, 11:36 AM

Modified check-lines based on Matt's comments.

arsenm added inline comments.Sep 6 2016, 4:18 PM
test/MC/AMDGPU/vop3.s
363 ↗(On Diff #70439)

CIVI doesn't make sense, and you don't have such a prefix. You need a separate CI and VI check line for this

wdng updated this revision to Diff 70537.Sep 7 2016, 8:14 AM

Separate CI and VI check lines.

arsenm added inline comments.Sep 8 2016, 1:00 PM
test/MC/AMDGPU/vop3.s
363 ↗(On Diff #70537)

The check prefix is SICI but you are only using CI here

wdng added inline comments.Sep 8 2016, 2:07 PM
test/MC/AMDGPU/vop3.s
363 ↗(On Diff #70537)

But v_mqsad won't work on SI, so I separate CI and VI for this test. For SI, NOSI is used to check the stderr.

arsenm added inline comments.Sep 8 2016, 3:06 PM
test/MC/AMDGPU/vop3.s
363 ↗(On Diff #70537)

That doesn't matter, you just need to use the same check prefix. CI isn't a check prefix so it isn't checking anything

wdng added inline comments.Sep 9 2016, 9:08 AM
test/MC/AMDGPU/vop3.s
363 ↗(On Diff #70537)

If I change it to:
// SICI: v_mqsad_u32_u8 v[0:3], s[2:3], v4, v[0:3] ; encoding: [0x00,0x00,0xe7,0xd1,0x02,0x08,0x02,0x04]

It failed with the following error:

/llvm/test/MC/AMDGPU/vop3.s:362:1: error: instruction not supported on this GPU
v_mqsad_u32_u8 v[0:3], s[2:3], v4, v[0:3]
^
/llvm/test/MC/AMDGPU/vop3.s:363:10: error: expected string not found in input
// SICI: v_mqsad_u32_u8 v[0:3], s[2:3], v4, v[0:3] ; encoding: [0x00,0x00,0xe7,0xd1,0x02,0x08,0x02,0x04]

arsenm added inline comments.Sep 9 2016, 9:48 AM
test/MC/AMDGPU/vop3.s
363 ↗(On Diff #70537)

You need to use a CI specific checkline

wdng updated this revision to Diff 70872.Sep 9 2016, 11:16 AM
wdng marked 5 inline comments as done.

Add a separate CI check-line.

arsenm added inline comments.Sep 9 2016, 11:32 AM
test/MC/AMDGPU/vop3.s
4 ↗(On Diff #70872)

tonga is not CI

wdng updated this revision to Diff 70875.Sep 9 2016, 11:41 AM

Set mcpu=hawaii for CI.

arsenm accepted this revision.Sep 9 2016, 11:44 AM
arsenm edited edge metadata.

LGTM

This revision is now accepted and ready to land.Sep 9 2016, 11:44 AM
This revision was automatically updated to reflect the committed changes.