This is an archive of the discontinued LLVM Phabricator instance.

[SLP] Pass VecPred argument to getCmpSelInstrCost.
ClosedPublic

Authored by fhahn on Oct 25 2020, 10:40 AM.

Details

Summary

Check if all compares in VL have the same predicate and pass it to
getCmpSelInstrCost, to improve cost-modeling on targets that only
support compare/select combinations for certain uniform predicates.

This leads to additional vectorization in some cases

Same hash: 217 (filtered out)
Remaining: 19
Metric: SLP.NumVectorInstructions

Program                                        base    slp2    diff
 test-suite...marks/SciMark2-C/scimark2.test    11.00   26.00  136.4%
 test-suite...T2006/445.gobmk/445.gobmk.test    79.00  135.00  70.9%
 test-suite...ediabench/gsm/toast/toast.test    54.00   71.00  31.5%
 test-suite...telecomm-gsm/telecomm-gsm.test    54.00   71.00  31.5%
 test-suite...CI_Purple/SMG2000/smg2000.test   426.00  542.00  27.2%
 test-suite...ch/g721/g721encode/encode.test    30.00   24.00  -20.0%
 test-suite...000/186.crafty/186.crafty.test   116.00  138.00  19.0%
 test-suite...ications/JM/ldecod/ldecod.test   697.00  765.00   9.8%
 test-suite...6/464.h264ref/464.h264ref.test   822.00  886.00   7.8%
 test-suite...chmarks/MallocBench/gs/gs.test   154.00  162.00   5.2%
 test-suite...nsumer-lame/consumer-lame.test   621.00  651.00   4.8%
 test-suite...lications/ClamAV/clamscan.test   223.00  231.00   3.6%
 test-suite...marks/7zip/7zip-benchmark.test   680.00  695.00   2.2%
 test-suite...CFP2000/177.mesa/177.mesa.test   2121.00 2129.00  0.4%
 test-suite...:: External/Povray/povray.test   2406.00 2412.00  0.2%
 test-suite...TimberWolfMC/timberwolfmc.test   634.00  634.00   0.0%
 test-suite...CFP2006/433.milc/433.milc.test   1036.00 1036.00  0.0%
 test-suite.../Benchmarks/nbench/nbench.test   321.00  321.00   0.0%
 test-suite...ctions-flt/Reductions-flt.test    NaN      5.00   nan%

Diff Detail

Event Timeline

fhahn created this revision.Oct 25 2020, 10:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 25 2020, 10:40 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
fhahn requested review of this revision.Oct 25 2020, 10:40 AM
dmgreen added inline comments.Oct 25 2020, 2:17 PM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
3560

This doesn't set First to false, and should the == be !=?

fhahn updated this revision to Diff 300557.Oct 25 2020, 2:24 PM

Fix check, thanks!

fhahn added inline comments.Oct 25 2020, 2:26 PM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
3560

Whops, looks like I did not adjust that after initially moving some code around :( Should be fixed now. I am not sure if there's a way we can currently exercise this with a test, because I am not sure if we ever vectorize compares that do have different conditions.

Thanks. This looks very sensible to me but I don't know a huge amount about the inner workings of the SLP vectorizer. It looks straight forward enough, but hopefully someone more knowledgeable can say more.

RKSimon accepted this revision.Oct 28 2020, 3:54 AM

LGTM

This revision is now accepted and ready to land.Oct 28 2020, 3:54 AM
fhahn updated this revision to Diff 302511.Nov 3 2020, 1:55 AM

Rebase, will land soon.

This revision was landed with ongoing or failed builds.Nov 3 2020, 2:17 AM
This revision was automatically updated to reflect the committed changes.