[PATCH] D81756: [SCCP] Turn sext into zext for positive ranges.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 12 12:35:17 PDT 2020


fhahn created this revision.
fhahn added reviewers: efriedma, davide.
Herald added subscribers: javed.absar, hiraditya.
Herald added a project: LLVM.

This patch updates SCCP/IPSCCP to use the computed range info to turn
sexts into zexts, if the value is known to be non-negative. We already
to a similar transform in CorrelatedValuePropagation, but it seems like
we can catch a lot of additional cases by doing it in SCCP/IPSCCP as
well.

The transform is limited to ranges that are known to not include undef.
For it to be effective, we have to flip the MayIncludeUndef flag when
constructing ranges from predicates. That should be in line with the
recent LangRef updates, but may expose problems in other passes not
expecting branches on undef to be UB. But it might be good to start
making more aggressive use of the LangRef update and fix issues
uncovered. Alternatively we could wait until the 11.0 release branch is
taken.

Without this patch, CorrelatedValuePropagation turns ~6400 sexts into
zexts on MultiSource, SPEC2000 & SPEC2006. With this patch, CVP
transforms around 4000, while IPSCCP transforms around 10000.

This change impacts 90 binaries (147 unchanged). One interesting impact
is that this leads to a few more loops getting vectorized, probably
because reasoning about zexts is easier than about sexts in SCEV & co:

Program                                        base   patch3 diff
 test-suite...T2000/256.bzip2/256.bzip2.test    20.00  21.00  5.0%
 test-suite...T2006/401.bzip2/401.bzip2.test    22.00  23.00  4.5%
 test-suite...0.perlbench/400.perlbench.test    84.00  87.00  3.6%
 test-suite.../CINT2000/176.gcc/176.gcc.test    90.00  93.00  3.3%
 test-suite...lications/ClamAV/clamscan.test    91.00  92.00  1.1%
 test-suite.../CINT2006/403.gcc/403.gcc.test   220.00 222.00  0.9%
 test-suite...pplications/oggenc/oggenc.test   126.00 127.00  0.8%
 test-suite...arks/mafft/pairlocalalign.test   319.00 321.00  0.6%
 test-suite...marks/7zip/7zip-benchmark.test   374.00 375.00  0.3%


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81756

Files:
  llvm/lib/Transforms/Scalar/SCCP.cpp
  llvm/test/Transforms/SCCP/ip-ranges-casts.ll
  llvm/test/Transforms/SCCP/ip-ranges-sext.ll
  llvm/test/Transforms/SCCP/ranges-sext.ll
  llvm/test/Transforms/SCCP/widening.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81756.270484.patch
Type: text/x-patch
Size: 8470 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200612/6f20d0c2/attachment.bin>


More information about the llvm-commits mailing list