We add rules for sub, mul, udiv, urem, shl, and &&. We also add
strengthened rule for add to work for all Values, and not just
constants. We have to check for zeros for mul, div, and urem.
Details
- Reviewers
goldstein.w.n nikic arsenm
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I predicted this is going to happen in https://reviews.llvm.org/D149510#4315073, and now it is happening. You are reimplementing InstSimplify comparison folding in isTruePredicate().
Oops. I thought this was a draft.
I can give an attempt at using SimplifyICmpInst as you mentioned, and see how much compile time is impacted.
I'm not aware of where in InstSimplify this is re-implementing. simplifyICmp() and simplifyICmpOfBools() both make calls out to isTruePredicate(). Passing in the test examples to places like InstCombine or ConstraintElimination does not simplify. I don't believe existing logic to simplify these cases exists right now.
I believe that isTruePredicate() is the correct place to put this logic right now. I agree with your concerns on writing a bunch of different rules, but I don't see another way if we want to optimize these cases (maybe pick out the ones that are more useful, like subtraction).
I don't follow. isTruePredicate() is a static function in ValueTracking, so how can InstSimplify call it?
You should be able to find the cases you're duplicating in simplifyICmpWithBinOpOnLHS().