This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Use consistent type sizes for opcode
ClosedPublic

Authored by mbrkusanin on Oct 7 2022, 8:59 AM.

Diff Detail

Event Timeline

mbrkusanin created this revision.Oct 7 2022, 8:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 7 2022, 8:59 AM
mbrkusanin requested review of this revision.Oct 7 2022, 8:59 AM

Not sure if I picked the right reviewers.
A downstream target broke because it exceeded 32768 opcodes.

Are you seeing much change in memory usage?

What is sizeof(SDNode) before and after?

I ran a test with 100 fadd float instructions ('-debug' reported 106 nodes) and measured memory with '--time-passes -track-memory' option.
There were small differences in reported memory between runs (not sure what is the reason for this).
Here are the results for 10 runs for 'AMDGPU DAG->DAG Pattern Instruction Selection' pass:

int16_t

205696
204768
204816
206528
206528
205696
205696
205648
206528
204816

avg = 205672

int32_t

209808
209808
210640
209760
209808
209808
210640
209808
210640
209808

avg = 210052.8

increase:
210052.8 / 205672 = 1.0212999338753

Other passes were mostly indentical with small variations between runs.

sizeof(SDNode) went from 88 to 96.

foad added a comment.Oct 12 2022, 7:22 AM

sizeof(SDNode) went from 88 to 96.

NodeType and NodeBitfields are supposed to pack into a 32-bit word. Maybe you could swap "uint16_t PersistentId;" to the start of the struct instead, and pack that with the NodeBitfields, to avoid increasing the size?

sizeof(SDNode) went from 88 to 96.

NodeType and NodeBitfields are supposed to pack into a 32-bit word. Maybe you could swap "uint16_t PersistentId;" to the start of the struct instead, and pack that with the NodeBitfields, to avoid increasing the size?

Great idea. That works. SDNode size is now 88.

'--time-passes -track-memory' now looks identical.

foad added inline comments.Oct 12 2022, 7:54 AM
llvm/include/llvm/CodeGen/SelectionDAGNodes.h
477

"with PersistentId"

  • Updated comment.
mbrkusanin marked an inline comment as done.Oct 12 2022, 8:07 AM
foad accepted this revision.Oct 12 2022, 8:07 AM
This revision is now accepted and ready to land.Oct 12 2022, 8:07 AM
arsenm accepted this revision.Oct 12 2022, 8:22 AM