This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Combine G_INSERT/EXTRACT_VECTOR_ELT with out of bounds indices to undef.
ClosedPublic

Authored by aemerson on Sep 5 2022, 8:17 AM.

Diff Detail

Event Timeline

aemerson created this revision.Sep 5 2022, 8:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 5 2022, 8:17 AM
aemerson requested review of this revision.Sep 5 2022, 8:17 AM
tschuett added inline comments.Sep 5 2022, 8:34 AM
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
2337

Nit. The text is missing.

2342

If Idx is an optional, then you don't need the has_value.

aemerson updated this revision to Diff 458046.Sep 5 2022, 11:23 AM

Address comments.

foad added inline comments.Sep 6 2022, 1:36 AM
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
2345–2346

See discussion on D132978. I think we should be treating these indices as unsigned, so I would suggest just return Idx->getZExtValue() >= VecTy.getNumElements(). The behaviour should be the same as what you have written except in weird cases where the type of Idx is very narrow.

aemerson added inline comments.Sep 6 2022, 3:29 AM
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
2345–2346

Great, D132978 is a good clean up for the IR.

aemerson updated this revision to Diff 458137.Sep 6 2022, 4:07 AM

Zero extend instead of sign-extend.

foad accepted this revision.Sep 6 2022, 5:28 AM

LGTM.

This revision is now accepted and ready to land.Sep 6 2022, 5:28 AM
This revision was landed with ongoing or failed builds.Sep 6 2022, 5:45 AM
This revision was automatically updated to reflect the committed changes.