This is an archive of the discontinued LLVM Phabricator instance.

[CGP / PowerPC] use direct compares if there's only one load per block in memcmp() expansion
ClosedPublic

Authored by spatel on Jun 6 2017, 3:42 PM.

Details

Summary

I'd like to enable CGP memcmp expansion for x86, but the output from CGP would regress the special cases (memcmp(x,y,N) != 0 for N=1,2,4,8,16,32 bytes) that we already handle.

I'm not sure if we'll actually be able to produce the optimal code given the block-at-a-time limitation in the DAG. We might have to just avoid those special-cases here in CGP. But regardless of that, I think this is a win for the more general cases.

http://rise4fun.com/Alive/cbQ

Diff Detail

Repository
rL LLVM

Event Timeline

spatel created this revision.Jun 6 2017, 3:42 PM
efriedma added inline comments.Jun 6 2017, 4:16 PM
lib/CodeGen/CodeGenPrepare.cpp
1872 ↗(On Diff #101635)

Use of uninitialized variable?

spatel added inline comments.Jun 6 2017, 4:19 PM
lib/CodeGen/CodeGenPrepare.cpp
1872 ↗(On Diff #101635)

Whoops! Yes...and hmm...no warning from clang.

spatel updated this revision to Diff 101642.Jun 6 2017, 4:20 PM

Patch updated:

  1. Initialize 'Cmp' with null.
  2. Use CreateICmpNE() to shorten code.
efriedma accepted this revision.Jun 6 2017, 4:27 PM

LGTM. (We could match this in DAGCombine, but probably not worth bothering.)

This revision is now accepted and ready to land.Jun 6 2017, 4:27 PM
This revision was automatically updated to reflect the committed changes.