[PATCH] D156657: [InstCombine] Fold icmp(constants[x]) when the range of x is given

Hongyu Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 2 11:46:09 PDT 2023

XChy marked an inline comment as not done.
XChy added a comment.

In D156657#4550996 <https://reviews.llvm.org/D156657#4550996>, @XChy wrote:

> Already limit it to one variable. But I don't know why it is unlikely to be useful. From my perspective For multi-dimensional arrays, it's possible to have more than one index variable.
> Besides, there exists miscompilation, I found just now.  Current state-machine doesn't emit the CmpInst/Poison to guarrantee the index/offset is always not negative. Lack of such range-check would lead to something triggering UB not to doing so. I need to check it later.

After trying, I don't think there is any way to do boundary-check (let things out of boundary lead to `load poison`) without modifying CFG. But InstCombine doesn't modify CFG. I haven't better idea here.



More information about the llvm-commits mailing list