[llvm] [SDAG] Introduce inbounds flag for ISD::PTRADD (PR #162477)
Fabian Ritter via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 9 02:14:33 PDT 2025
ritter-x2a wrote:
@efriedma-quic
(I'm not disagreeing with the point and will add a corresponding warning comment; this is just for me to better understand the problem.)
Could you give an example of an optimization that doesn't work?
Would for example a `(ptradd inbounds (ptradd inbounds p, a), b) -> (ptradd inbounds p, (a + b))` DAGCombine be problematic?
The pointer operand of the outer ptradd on the left-hand side is only based on p, so it looks like if the two ptradds on the left-hand side are inbounds, the one on the right can be inbounds as well.
Do you argue that the original IR could have been something like
```
p2 = gep inbounds p, a
x1 = ptrtoint p2
x2 = add p2, something_based_on_a_different_object_that_happens_to_be_zero
p3 = inttoptr x2
p4 = gep inbounds p3, b
```
and the inbounds-ness of the outer ptradd / the last gep hinges on the `something_...` addition that was optimized away?
https://github.com/llvm/llvm-project/pull/162477
More information about the llvm-commits
mailing list