This is an archive of the discontinued LLVM Phabricator instance.

Introduce metadata for avoiding loop predication
AbandonedPublic

Authored by anna on Mar 15 2018, 1:11 PM.

Details

Summary

This patch introduces the llvm.cond.no_loop_predication which will be
annotated on boolean conditions that are used in branches.
This is used by loop predication to identify loops that should not be
predicated. When the conditional instruction is used as the latch check
in the loop, predicating the loop can cause the widened checks to fail
spuriously.
Such coarse checks (which can later become the latch check through
passes such as loop rotate) can be introduced by the front end or by
downstream passes. Given this metadata is a property of the condition,
we cannot attach it to llvm.loop metadata.

Diff Detail

Event Timeline

anna created this revision.Mar 15 2018, 1:11 PM
anna abandoned this revision.Mar 16 2018, 10:31 AM

Artur had an idea offline that we could use BPI to identify if the latch exit is very rarely taken compared to other exits in the loop. We can teach loop predication to use that information and avoid predication, instead of depending on llvm.cond.donot_predicate metadata.

I'm going to abandon this revision for now and get back in case the above idea of using BPI doesn't pan out for some reason.