Page MenuHomePhabricator

Jump thread llvm.expect

Authored by pete on Jan 25 2015, 9:49 PM.



When jump threading this code

%B = phi i32 [%v1, %T1], [12, %F1]
%A = icmp ne i32 %B, 42

in asserts builds its common to have an expect in between:

%B = phi i64 [%v1, %T1], [12, %F1]
%expect = call i64 @llvm.expect.i64(i64 %B, i64 42)
%A = icmp ne i64 %expect, 42

This patch teaches JumpThreading about this case so that when we fail to find a PHI, we look through an llvm.expect to see if a PHI is its first source.

Reduces the size of an LTO'd llc by almost 2.5%.

Diff Detail

Event Timeline

pete updated this revision to Diff 18740.Jan 25 2015, 9:49 PM
pete retitled this revision from to Jump thread llvm.expect.
pete updated this object.
pete edited the test plan for this revision. (Show Details)
pete added a reviewer: hfinkel.
pete added a subscriber: Unknown Object (MLST).
reames added a subscriber: reames.Jan 26 2015, 10:19 AM

Looks straight forward. Provided your confident of the answer to my inline question, LGTM.


Can the PHITranslation now fail with your change?


Please use CHECK-LABEL so this file is easy to extend later.

Also, comment description at top of file should be clearer.

pete abandoned this revision.Jan 26 2015, 11:55 AM supersedes this. Thanks to Chandler for the idea.