[PATCH] D113079: [InstCombine] Take arguments into consideration when simplify range check
guopeilin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 3 01:29:29 PDT 2021
guopeilin added a comment.
Sorry for the absence of the description.
Actually, it is a runtime error. The simplify range check optimization will change `(icmp slt x, 0) | (icmp sgt x, n) ` into `icmp ugt x, n`
Now, suppose the %0 is `negative`, Before optimizing, we will compare the argument with 0 to see whether the argument is less than 0, if so, we will finally return `shl i32 %0, 0`.
However, after optimizing, we will not have this comparison, and we will finally return `shl i32 %0, %and`. The problem is that `%and` is also driven from the argument, it can be undefined cause it is a shift operation that depends on the argument. So, after optimization, we will get an undefined result.
So, I guess that if both `x` and `n` in `(icmp slt x, 0) | (icmp sgt x, n) ` are derived from the argument, then we should be conservative.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113079/new/
https://reviews.llvm.org/D113079
More information about the llvm-commits
mailing list