Page MenuHomePhabricator

[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

Unit TestsFailed

TimeTest
40 msx64 debian > LLVM.Transforms/InstCombine::extractelement-inseltpoison.ll
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/llvm-project/build/bin/opt < /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/InstCombine/extractelement-inseltpoison.ll -instcombine -S -data-layout="e" | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck --allow-unused-prefixes=false /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/InstCombine/extractelement-inseltpoison.ll --check-prefixes=ANY,LE
50 msx64 debian > LLVM.Transforms/InstCombine::extractelement.ll
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/llvm-project/build/bin/opt < /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/InstCombine/extractelement.ll -instcombine -S -data-layout="e" | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck --allow-unused-prefixes=false /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/InstCombine/extractelement.ll --check-prefixes=ANY,LE
80 msx64 debian > LLVM.Transforms/SLPVectorizer/X86::alternate-int-inseltpoison.ll
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/llvm-project/build/bin/opt < /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/SLPVectorizer/X86/alternate-int-inseltpoison.ll -mtriple=x86_64-unknown -basic-aa -slp-vectorizer -instcombine -S | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck --allow-unused-prefixes=false /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/SLPVectorizer/X86/alternate-int-inseltpoison.ll --check-prefixes=CHECK,SSE
70 msx64 debian > LLVM.Transforms/SLPVectorizer/X86::alternate-int.ll
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/llvm-project/build/bin/opt < /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/SLPVectorizer/X86/alternate-int.ll -mtriple=x86_64-unknown -basic-aa -slp-vectorizer -instcombine -S | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck --allow-unused-prefixes=false /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/SLPVectorizer/X86/alternate-int.ll --check-prefixes=CHECK,SSE
70 msx64 windows > LLVM.Transforms/InstCombine::extractelement-inseltpoison.ll
Script: -- : 'RUN: at line 2'; c:\ws\w32-1\llvm-project\premerge-checks\build\bin\opt.exe < C:\ws\w32-1\llvm-project\premerge-checks\llvm\test\Transforms\InstCombine\extractelement-inseltpoison.ll -instcombine -S -data-layout="e" | c:\ws\w32-1\llvm-project\premerge-checks\build\bin\filecheck.exe --allow-unused-prefixes=false C:\ws\w32-1\llvm-project\premerge-checks\llvm\test\Transforms\InstCombine\extractelement-inseltpoison.ll --check-prefixes=ANY,LE
View Full Test Results (8 Failed)

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
4402

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
4402

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 ↗(On Diff #315027)

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.