This is an archive of the discontinued LLVM Phabricator instance.

SelectionDAG: Swap operands of atomic_store
ClosedPublic

Authored by arsenm on Apr 5 2022, 9:56 AM.

Details

Summary

Irritatingly, atomic_store had operands in the opposite order from
regular store. This made it difficult to share patterns between
regular and atomic stores.

There was a previous incomplete attempt to move atomic_store into the
regular StoreSDNode which would be better.

I think it was a mistake for all atomicrmw to swap the operand order,
so maybe it's better to take this one step further.

Diff Detail

Event Timeline

arsenm created this revision.Apr 5 2022, 9:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 9:56 AM
arsenm requested review of this revision.Apr 5 2022, 9:56 AM

This will be a lot of fun downstream...

llvm/lib/Target/AMDGPU/AMDGPUInstructions.td
551

This contains a separate change?

llvm/lib/Target/ARM/ARMInstrInfo.td
4169

Unrelated

llvm/lib/Target/AVR/AVRInstrInfo.td
1468

God this style is awful, looks like it's trying to be GNU extended asm syntax

llvm/lib/Target/Hexagon/HexagonPatterns.td
2716–2724

Keep these lined up?

llvm/test/TableGen/GlobalISelEmitter-atomic_store.td
7–8

This comment seems to no longer apply

arsenm updated this revision to Diff 420582.Apr 5 2022, 11:08 AM
arsenm marked 3 inline comments as done.

Address comments

foad added inline comments.Apr 6 2022, 5:57 AM
llvm/include/llvm/Target/TargetSelectionDAG.td
1721

Before your patch, where were these defined?

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
1959

Rename to Op1?

craig.topper added inline comments.Apr 6 2022, 8:22 AM
llvm/include/llvm/Target/TargetSelectionDAG.td
1721

I think binary_atomic_op from the below line expanded to the 4 sizes.

defm atomic_store     : binary_atomic_op<atomic_store>
kparzysz accepted this revision.May 6 2022, 7:04 AM

This is great. I think there is an unaddressed comment, but otherwise LGTM.

This revision is now accepted and ready to land.May 6 2022, 7:04 AM
nemanjai added inline comments.May 8 2022, 8:50 AM
llvm/include/llvm/CodeGen/SelectionDAGNodes.h
1461–1466

I think this is quite problematic for downstream, out of tree code. If I'm not mistaken, the operands of the node simply get reversed, silently causing failures.

Perhaps we should implement new overloads of these and getOperand() with a new parameter to indicate that the caller is aware of the change and make the original ones hit an unreachable (this would of course be limited to ATOMIC_STORE). Changing all in-tree callers allows this to continue to work whereas any downstream code that is unaware of the change will simply break.

llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td
206

What do we gain by reordering the defs of the load and store in this patch?

arsenm added inline comments.Aug 31 2023, 2:19 PM
llvm/include/llvm/CodeGen/SelectionDAGNodes.h
1461–1466

It's only silent if you have no test coverage. This also wouldn't help the tablegen patterns at all

llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td
206

Keeps the two store and load cases together. Right now the atomic cases are together, but the atomics are closer to aliases

arsenm marked 2 inline comments as done.Aug 31 2023, 2:26 PM