This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] Pass pointer and indices separately to SimplifyGEPInst.
ClosedPublic

Authored by fhahn on Jan 11 2022, 9:58 AM.

Details

Summary

This doesn't require callers to put the pointer operand and the indices
in a container like a vector when calling the function. This is not
really an issue with the existing callers. But when using it from
IRBuilder the inputs are available as separate pointer value and indices
ArrayRef.

Diff Detail

Event Timeline

fhahn created this revision.Jan 11 2022, 9:58 AM
fhahn requested review of this revision.Jan 11 2022, 9:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 11 2022, 9:58 AM
lebedev.ri added inline comments.Jan 11 2022, 10:52 AM
llvm/lib/Analysis/InstructionSimplify.cpp
4086

?

4445–4449

Have you tried

auto Ops = llvm::concat<Value*>(makeArrayRef(Ptr), Indices);

?

fhahn added inline comments.Jan 11 2022, 12:23 PM
llvm/lib/Analysis/InstructionSimplify.cpp
4445–4449

I gave that a try try the issue is that the iterator type of ArrayRef<Value *> is Value * const *. concat<Value*> has a helper that returns ValueTy * with ValueTy = Value *, which unfortunately breaks. Adjusting SimplifyGEPInst was easier in that case (not a great justification, I know), but the distinction between ptr & indices makes at least some sense I think.

lebedev.ri accepted this revision.Jan 11 2022, 12:44 PM

Meh. LGTM.
I've read through the diff, looks about right, but hopefully some test would break if there was something wrong :)

This revision is now accepted and ready to land.Jan 11 2022, 12:44 PM