This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] For vector extract when extract vector and insert value type is the same
ClosedPublic

Authored by CarolineConcatto on Aug 18 2022, 7:44 AM.

Details

Summary

This patch has implements these optimizations:

extract.vector(insert.vector(Vector, Value, Idx), Idx) --> Value

extract.vector(insert.vector(Vector, Value, InsertIndex), ExtractIndex)

--> extract.vector(Vector, ExtractIndex)

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2022, 7:44 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
CarolineConcatto requested review of this revision.Aug 18 2022, 7:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2022, 7:44 AM
This revision is now accepted and ready to land.Aug 19 2022, 3:39 AM

Perhaps it is worth noting that this code follows from code we had for svget/svset, which will be removed in D131548.

reames added a subscriber: reames.Aug 19 2022, 7:17 AM
reames added inline comments.
llvm/test/Transforms/InstCombine/opts-tuples-extract-intrinsic.ll
20

I am not sure this transform is correct.

My understanding of the documentation is that these are inserting *vectors* not single elements. Given that, don't we need to prove that the vectors don't overlap?

In this example, if vscale = 6 on real hardware, isn't this transform unsound?

If it is sound, the semantics of the insert/extract intrinsics are non-obvious with regards to indexing, and the docs could be improved.