This is an archive of the discontinued LLVM Phabricator instance.

Use the new 'InvariantInfo' property to eliminate redundant loads with --instcombine
Needs ReviewPublic

Authored by lvoufo on Oct 22 2015, 9:12 PM.

Details

Summary

Similar to GVN in D14004: While processing instructions in InstCombine, mark global variables and alloca instructions corresponding to each encountered invariant intrinsic call as indicating 'writeonce' memory locations that either have been written into or can be written into again (once). Then, while scanning instructions backwards looking for available loads for a given memory location, be sure to temporarily disable or reset the markings, as appropriate.

This patch is a break-down of (corrected) D13606.

Diff Detail

Event Timeline

lvoufo updated this revision to Diff 38205.Oct 22 2015, 9:12 PM
lvoufo retitled this revision from to Use the new 'InvariantInfo' property to eliminate redundant loads with --instcombine.
lvoufo updated this object.
lvoufo added reviewers: nlewycky, reames, dberlin.
lvoufo added a subscriber: llvm-commits.
nlewycky edited edge metadata.Nov 8 2015, 4:00 PM

Patch needs testcases.

lib/Transforms/InstCombine/InstructionCombining.cpp
1961

Why bother? We're guaranteed to visit the invariant.start and the invariant.end, right? Just handle invariant_start by replacing it with an undef, and let the generic "EraseInstFromFunction" call (below on line 1975) handle the invariant.end?

I think the other case is an invariant applying to a bitcast instead of to the original object. Does this function work in that case? (Does it even pass isAllocSiteRemovable?)

reames resigned from this revision.Apr 18 2016, 4:55 PM
reames removed a reviewer: reames.