This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] Fold insertelement vec, poison, idx into vec
ClosedPublic

Authored by aqjune on Jan 3 2021, 9:05 AM.

Details

Summary

This is a simple patch that adds folding from insertelement vec, poison, idx into vec.

Alive2 proof: https://alive2.llvm.org/ce/z/2y2vbC

Diff Detail

Event Timeline

aqjune created this revision.Jan 3 2021, 9:05 AM
aqjune requested review of this revision.Jan 3 2021, 9:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 3 2021, 9:05 AM
nikic added inline comments.Jan 3 2021, 9:08 AM
llvm/lib/Analysis/InstructionSimplify.cpp
4407

You can also switch this to use isGuaranteedNotToBePoison() to be more precise.

aqjune updated this revision to Diff 314485.Jan 4 2021, 5:20 PM

Address comment

aqjune marked an inline comment as done.Jan 4 2021, 5:21 PM
aqjune added inline comments.
llvm/lib/Analysis/InstructionSimplify.cpp
4407

Made D94053 to make the function distinguish constant vector with undef elements but not poison. :)

aqjune marked an inline comment as done.Jan 4 2021, 5:21 PM
nikic added a comment.Jan 5 2021, 11:59 AM

It looks like there are some test failures.

aqjune added a comment.Jan 5 2021, 6:50 PM

Oh yes, I'll look into them

aqjune updated this revision to Diff 314790.Jan 5 2021, 8:26 PM

Resolve failures
A few of those was regressions. It was because ConstantVector::get(Arr) was unable to understand Poison array. I updated those.

If the diffs look okay, I'll split this into two commits (one with the ConstantVector and another one with the InstSimplify) when landing.

nikic accepted this revision.Jan 6 2021, 9:58 AM

LGTM. Nice catch on the ConstantVector issue.

This revision is now accepted and ready to land.Jan 6 2021, 9:58 AM
This revision was landed with ongoing or failed builds.Jan 6 2021, 5:10 PM
This revision was automatically updated to reflect the committed changes.
aqjune added inline comments.Jan 6 2021, 5:17 PM
llvm/test/Transforms/SLPVectorizer/X86/alternate-int.ll
428–431

I think something is happening here, I imagine some transformation is passing undef to SimplifyInsertElementInst instead of poison (because sdiv _, undef is simplified to poison) I will look into this later.