This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine][NFC] Baseline tests for D137212 Simplify chain of GEP with constant indices
Needs ReviewPublic

Authored by huangjd on Nov 8 2022, 12:29 PM.

Details

Summary

Baseline tests showing current optimizer can't simplify GEP (GEP (GEP p C1) I1) C2 where C1 and C2 are constants

Diff Detail

Event Timeline

huangjd created this revision.Nov 8 2022, 12:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2022, 12:29 PM
huangjd requested review of this revision.Nov 8 2022, 12:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2022, 12:29 PM
spatel added inline comments.Nov 10 2022, 12:30 PM
llvm/test/Transforms/InstCombine/gep-merge-constant-indices.ll
277

It's not clear to me that this test is providing coverage for the intended constraint in the other patch.

Should we add a simplify for any gep like %3?
https://alive2.llvm.org/ce/z/w89_Y5

huangjd added inline comments.Nov 10 2022, 4:00 PM
llvm/test/Transforms/InstCombine/gep-merge-constant-indices.ll
277

GEP with zero offset is simplified away by visitGEPOfGEP regardless what the preceding GEP is, so there is no way to keep it in the output

spatel added inline comments.Nov 11 2022, 7:52 AM
llvm/test/Transforms/InstCombine/gep-merge-constant-indices.ll
277

Then do we really need this test?

Even with typed pointers, we could do this transform of a single GEP:
https://alive2.llvm.org/ce/z/EKc-rM
...but that transform does not exist. Is there a reason it does not exist?

To be clear, I don't think it has to delay this patch or D137212. I'm just curious if we are missing a more basic transform.