This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] add folds for or-of-casted-icmps
ClosedPublic

Authored by spatel on May 4 2017, 11:52 AM.

Details

Summary

The sibling folds for 'and' with casts were added with https://reviews.llvm.org/rL273200.
This is a preliminary step for adding the 'or' variants for the folds added with https://reviews.llvm.org/rL301260.

The reason for the strange form with constant LHS in the 1st test is because there's another missing fold in that case for the inverted predicate. That should be fixed when we add the ConstantRange functionality for 'or-of-icmps' that already exists for 'and-of-icmps'.

I'm not sure yet why the vector constant expression is not simplified in the 2nd test.

I'm hoping to share more code for the and/or cases, so we won't have these differences. This will allow us to remove code from InstCombine. It's also possible that we can remove some code here in InstSimplify. I think we have some duplicated folds because patterns are not matched in a general way.

Diff Detail

Event Timeline

spatel created this revision.May 4 2017, 11:52 AM
efriedma accepted this revision.May 4 2017, 12:27 PM

LGTM.

The second testcase isn't getting folded because ConstantFoldCastOperand isn't getting called (you call ConstantExpr::getCast and never attempt to fold it). IIRC there was a thread recently about a similar problem with InstSimplify of GEPs.

This revision is now accepted and ready to land.May 4 2017, 12:27 PM
This revision was automatically updated to reflect the committed changes.