[PATCH] D20143: New pass: guard widening

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Tue May 10 17:10:05 PDT 2016


sanjoy created this revision.
sanjoy added reviewers: reames, atrick, bogner, apilipenko, nlewycky.
sanjoy added a subscriber: llvm-commits.
Herald added a subscriber: mcrosier.

Implement guard widening in LLVM. Description from GuardWidening.cpp:

The semantics of the `@llvm.experimental.guard` intrinsic lets LLVM
transform it so that it fails more often that it did before the
transform.  This optimization is called "widening" and can be used hoist
and common runtime checks in situations like these:

```
%cmp0 = 7 u< Length
call @llvm.experimental.guard(i1 %cmp0) [ "deopt"(...) ]
call @unknown_side_effects()
%cmp1 = 9 u< Length
call @llvm.experimental.guard(i1 %cmp1) [ "deopt"(...) ]
...
```

to

```
%cmp0 = 9 u< Length
call @llvm.experimental.guard(i1 %cmp0) [ "deopt"(...) ]
call @unknown_side_effects()
...
```

If `%cmp0` is false, `@llvm.experimental.guard` will "deoptimize" back
to a generic implementation of the same function, which will have the
correct semantics from that point onward.  It is always _legal_ to
deoptimize (so replacing `%cmp0` with false is "correct"), though it may
not always be profitable to do so.

http://reviews.llvm.org/D20143

Files:
  include/llvm/InitializePasses.h
  include/llvm/LinkAllPasses.h
  include/llvm/Transforms/Scalar.h
  include/llvm/Transforms/Scalar/GuardWidening.h
  lib/Passes/PassBuilder.cpp
  lib/Passes/PassRegistry.def
  lib/Transforms/Scalar/CMakeLists.txt
  lib/Transforms/Scalar/GuardWidening.cpp
  lib/Transforms/Scalar/Scalar.cpp
  test/Transforms/GuardWidening/basic.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20143.56840.patch
Type: text/x-patch
Size: 28806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160511/12100a0d/attachment.bin>


More information about the llvm-commits mailing list