Page MenuHomePhabricator

X86CallFrameOptimization: Recognize 'store 0/-1 using and/or' idioms
ClosedPublic

Authored by zvi on Oct 10 2017, 8:17 AM.

Details

Summary

r264440 added or/and patterns for storing -1 or 0 with the intention of decreasing code size. However,
X86CallFrameOptimization does not recognize these memory accesses so it will not replace them with push's when profitable.

This patch fixes this problem by teaching X86CallFrameOptimization these store 0/-1 idioms.

An alternative fix would be to prevent the 'store 0/1 idioms' patterns from firing when accessing the stack. This would save
the need to teach the pass about these idioms. However, because X86CallFrameOptimization does not always fire we may result
in cases where neither X86CallFrameOptimization not the patterns for 'store 0/1 idioms' fire.

Fixes pr34863

Diff Detail

Repository
rL LLVM

Event Timeline

zvi created this revision.Oct 10 2017, 8:17 AM
aymanmus accepted this revision.Oct 22 2017, 2:13 AM

Minor comments but LGTM overall.

lib/Target/X86/X86CallFrameOptimization.cpp
283 ↗(On Diff #118398)

The comment implies only movs are acceptable.
Please modify.

506 ↗(On Diff #118398)

Here also, the comments and variable names may be misleading.

test/CodeGen/X86/movtopush.ll
395 ↗(On Diff #118398)

Deleted word by mistake I guess.

This revision is now accepted and ready to land.Oct 22 2017, 2:13 AM
DavidKreitzer added inline comments.Oct 23 2017, 7:55 PM
test/CodeGen/X86/movtopush.ll
1 ↗(On Diff #118398)

It seems like similar changes are needed in movtopush64.ll.

zvi added inline comments.Oct 24 2017, 4:56 AM
lib/Target/X86/X86CallFrameOptimization.cpp
283 ↗(On Diff #118398)

ok

506 ↗(On Diff #118398)

Will fix the comment at commit-time. The variable names will be changed in a follow-up commit.

test/CodeGen/X86/movtopush.ll
1 ↗(On Diff #118398)

Will add the required tests.

395 ↗(On Diff #118398)

Whoops

This revision was automatically updated to reflect the committed changes.