This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Simplify binops that are only used by a select and are fed by a select with the same condition.
ClosedPublic

Authored by craig.topper on Nov 13 2017, 10:50 PM.

Details

Summary

This patch optimizes a binop sandwiched between 2 selects with the same condition. Since we know its only used by the select we can propagate the appropriate input value from the earlier select.

As I'm writing this I realize I may need to avoid doing this for division in case the select was protecting a divide by zero?

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Nov 13 2017, 10:50 PM
This revision is now accepted and ready to land.Nov 14 2017, 8:39 PM
This revision was automatically updated to reflect the committed changes.

It took a while, but automated testing caught that div/rem-by-0 possibility:
https://bugs.llvm.org/show_bug.cgi?id=36362