This patch teaches ScalarEvolution to pick and use !range metadata. It also makes it more aggressive in querying range information by adding a call to isKnownPredicateWithRanges to isLoopBackedgeGuardedByCond and isLoopEntryGuardedByCond.
Diff Detail
Event Timeline
Could you please post this patch with full context (see http://llvm.org/docs/Phabricator.html).
Also, looking at this patch made me think: We don't handle range metadata in LazyValueInfo, do we? And we don't seem to, and I think your GetRangeFromMetadata will be useful for both cases. You might consider making it a general utility function somewhere.
lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
3561 | You don't need {} here. | |
3562 | More importantly, don't return here. ValueTracking might be able to refine the range even more, and we want the range information to be additive. | |
3717 | Same comments apply here. |
The only other use I could find was in ValueTracking.cpp where the range metadata is used to compute "known bits". This information could be indirectly flowing in into LazyValueInfo, but I could not find any direct reference. I haven't look very hard either. :)
You might consider making it a general utility function somewhere.
What is a good place for that?
What is a good place for that?
Given that ConstantRange is in lib/IR, I think you could just add it to ConstantRange itself (as a static function, or a special intersection function, etc.).
The indvars test is great. Can you add more specific unit tests with -scalar-evolution -analyze to cover the cases that you analyze more aggressively now?
Otherwise LGTM. Thanks!
You don't need {} here.