[PATCH] D18867: [IndVarSimplify] Eliminate zext of a signed IV when the IV is known to be non-negative

Li Huang via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 27 11:38:46 PDT 2016


lihuang added a comment.

In https://reviews.llvm.org/D18867#403728, @sanjoy wrote:

> +1 to both comments by @mbodart
>
> Specifically with regards to the `isKnownNonNegative` comment:  if `isKnownPredicate` is failing here, you might consider teaching it to use `getSignedRange` internally, since the range SCEV computes for `%i.0` is `[0,-2147483648)` (all positive integers) so we should be able to use that information.


Hi Sanjoy,

This thread is old but I hope you could remember, sorry about this.

For this old issue, I tried different solutions but think I really need to use isKnownNonNegative here, because isKnownPredicate doesn't work because of the discrepancy of "nsw" flag between instruction and SCEV. The "nsw" flag propagation in SCEV based on poison value analysis is very conservative and only considers full poison propagation, so it doesn't work for this case. Loosing the flag propagation condition might be controversial and potentially a lot of work. The issues here could be easily solved by using isKnownNonNegative, which also solves the issue in https://reviews.llvm.org/D21773 which blocks https://reviews.llvm.org/D18777 and r274098.

Is there a strong reason against using ValueTracking's isKnownNonNegative here?

Thanks,
Li Huang


https://reviews.llvm.org/D18867





More information about the llvm-commits mailing list