[PATCH] D29519: Add PredicateInfo utility and printing pass

Daniel Berlin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 3 15:06:56 PST 2017


dberlin created this revision.
Herald added subscribers: Prazek, mgorny.

This patch adds a utility to build extended SSA (see "ABCD: eliminating
array bounds checks on demand"), and an intrinsic to support it. This
is then used to get functionality equivalent to propagateEquality in
GVN, in NewGVN (without having to replace instructions as we go). It
would work similarly in SCCP or other passes. This has been talked
about a few times, so i built a real implementation and tried to
productionize it.

Copies are inserted for operands used in assumes and conditional
branches that are based on comparisons (see below for more)

Every use affected by the predicate is renamed to the appropriate
intrinsic result.

E.g.
%cmp = icmp eq i32 %x, 50
br i1 %cmp, label %true, label %false
true:
ret i32 %x
false:
ret i32 1

will become

%cmp = icmp eq i32, %x, 50
br i1 %cmp, label %true, label %false
true:
; Has predicate info
; branch predicate info { TrueEdge: 1 Comparison: %cmp = icmp eq i32 %x, 50 }
%x.0 = call @llvm.predicateinfo.i32(i32 %x)
ret i32 %x.0
false:
ret i23 1

(you can use -print-predicateinfo to get an annotated-with-predicateinfo dump)

This enables us to easily determine what operations are affected by a
given predicate, and how operations affected by a chain of
predicates.


https://reviews.llvm.org/D29519

Files:
  include/llvm/InitializePasses.h
  include/llvm/Transforms/Utils/PredicateInfo.h
  lib/Passes/PassBuilder.cpp
  lib/Transforms/Utils/CMakeLists.txt
  lib/Transforms/Utils/PredicateInfo.cpp
  lib/Transforms/Utils/Utils.cpp
  test/Transforms/Util/PredicateInfo/condprop.ll
  test/Transforms/Util/PredicateInfo/testand.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29519.87042.patch
Type: text/x-patch
Size: 56994 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170203/5b1fc812/attachment.bin>


More information about the llvm-commits mailing list