This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] fix commuted case of sub combine
ClosedPublic

Authored by rampitec on Feb 20 2019, 4:14 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

rampitec created this revision.Feb 20 2019, 4:14 PM
rampitec retitled this revision from PATCH] AMDGPU: fix commuted case of sub combine to [AMDGPU] fix commuted case of sub combine.Feb 20 2019, 4:14 PM
arsenm added inline comments.Feb 20 2019, 5:13 PM
lib/Target/AMDGPU/SIISelLowering.cpp
8621 ↗(On Diff #187692)

This swap is hard to follow. It's not immediately clear to me why this would be commuted in != subcarry case. What happens in the sub (subcarry, subcarry) case? I think it would be clearer to just explicitly handle the two cases

8625 ↗(On Diff #187692)

This needs a comment with the commuted case

8626–8627 ↗(On Diff #187692)

This can use C->isNullValue() instead of getZExtValue

test/CodeGen/AMDGPU/combine-cond-add-sub.ll
151 ↗(On Diff #187692)

Maybe add a test where both operands to a sub are subcarry

rampitec marked 2 inline comments as done.Feb 20 2019, 5:17 PM
rampitec added inline comments.
lib/Target/AMDGPU/SIISelLowering.cpp
8621 ↗(On Diff #187692)

It really does not matter what is the RHS, it can be anything including subcarry.

test/CodeGen/AMDGPU/combine-cond-add-sub.ll
151 ↗(On Diff #187692)

That is really no different from any other instruction but complicates the test a lot since we cannot get subcarry right from the IR.

rampitec updated this revision to Diff 187700.Feb 20 2019, 5:25 PM
rampitec marked 2 inline comments as done.
arsenm accepted this revision.Feb 20 2019, 5:35 PM

LGTM

This revision is now accepted and ready to land.Feb 20 2019, 5:35 PM
rampitec planned changes to this revision.Feb 20 2019, 5:46 PM

Actually I think it is still wrong. In the commuted case carry must be added, not subtracted:

x - (y - 0 - cc) => x - y + cc

I will just disable it for commuted case.

rampitec updated this revision to Diff 187707.Feb 20 2019, 5:56 PM

Disabled commuted case completely.

This revision is now accepted and ready to land.Feb 20 2019, 5:56 PM
arsenm added inline comments.Feb 20 2019, 5:59 PM
test/CodeGen/AMDGPU/combine-cond-add-sub.ll
131–133 ↗(On Diff #187707)

This needs operand checks

rampitec updated this revision to Diff 187711.Feb 20 2019, 6:21 PM
rampitec marked an inline comment as done.
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 20 2019, 6:58 PM