[PATCH] D11648: InstCombinePHI: Partial simplification of identity operations

Jakub Kuderski jakub.kuderski at arm.com
Thu Jul 30 08:00:52 PDT 2015


kuhar created this revision.
kuhar added a subscriber: llvm-commits.
kuhar set the repository for this revision to rL LLVM.

Consider this code:
```
...
BB:
  %i = phi i32 [ 0, %if.then ], [ %c, %if.else ]
  %add = add nsw i32 %i, %b
  ...
````
In this common case the `add` can be moved to the `%if.else` basic block, because adding zero is an identity operation. If we go though `%if.then` branch it's always a win, because `add` is not executed; if not, the number of instructions stays the same.
This pattern applies also to other instructions like `sub, shl, shr, ashr | 0`, `mul, sdiv, div | 1`.

Repository:
  rL LLVM

http://reviews.llvm.org/D11648

Files:
  lib/Transforms/InstCombine/InstCombinePHI.cpp
  test/Transforms/InstCombine/phi.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11648.31027.patch
Type: text/x-patch
Size: 7989 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150730/0eb97482/attachment.bin>


More information about the llvm-commits mailing list