Page MenuHomePhabricator

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

Authored by aqjune on Sun, Jan 3, 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.Sun, Jan 3, 9:05 AM
aqjune requested review of this revision.Sun, Jan 3, 9:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptSun, Jan 3, 9:05 AM
nikic added inline comments.Sun, Jan 3, 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.Mon, Jan 4, 5:20 PM

Address comment

aqjune marked an inline comment as done.Mon, Jan 4, 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.Mon, Jan 4, 5:21 PM
nikic added a comment.Tue, Jan 5, 11:59 AM

It looks like there are some test failures.

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

Oh yes, I'll look into them

aqjune updated this revision to Diff 314790.Tue, Jan 5, 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.Wed, Jan 6, 9:58 AM

LGTM. Nice catch on the ConstantVector issue.

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

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.