This is an archive of the discontinued LLVM Phabricator instance.

[GISel] Add combine for constant G_PTR_ADD offsets.
ClosedPublic

Authored by pnappa on Oct 5 2020, 6:43 PM.

Details

Summary

This adds a single combine for GlobalISel to fold:

ptradd (inttoptr C1) C2

Into:

C1 + C2

Additionally, a small test for AArch64 is added.

Diff Detail

Event Timeline

pnappa created this revision.Oct 5 2020, 6:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 5 2020, 6:43 PM
pnappa requested review of this revision.Oct 5 2020, 6:43 PM
arsenm added inline comments.Oct 6 2020, 7:45 AM
llvm/include/llvm/Target/GlobalISel/Combine.td
538

Do we not have a constant fold group? Probably should

llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
2027

setInstrAndDebugLoc

2028

This can directly produce a pointer typed constant

pnappa updated this revision to Diff 296865.Oct 7 2020, 10:22 PM

Addressing Matt's comments

pnappa marked 3 inline comments as done.Oct 7 2020, 10:23 PM
aemerson accepted this revision.Oct 7 2020, 10:28 PM
aemerson added inline comments.
llvm/test/CodeGen/AArch64/GlobalISel/combine-ptradd-int2ptr.mir
16

FYI the integer in p64 doesn't mean the same thing as in s64. In s64 its the bit width, in p64 the integer denotes the address space of the pointer. We normally just use the default p0 on AArch64 because we only use one address space. It doesn't make a difference for this combine though.

This revision is now accepted and ready to land.Oct 7 2020, 10:28 PM