HomePhabricator

[InstCombinePHI] Partial simplification of identity operations.

Description

[InstCombinePHI] Partial simplification of identity operations.

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.

Patch by Jakub Kuderski!

Details

Committed
chatur01Aug 13 2015, 5:38 AM
Parents
rL244886: Removing redundant check from r244875
Branches
Unknown
Tags
Unknown