These transforms all perform a variant of (gep (gep p, x), y) to (gep p, (x + y)). We can preserve both inbounds and nuw during such transforms (https://alive2.llvm.org/ce/z/Stu4cN), but not nusw, which would require proving that the new add is nsw. For the constant offset case, I've conservatively retained the logic that checks for negative intermediate offsets, though I'm not sure it's still reachable nowadays.
66 KiB
66 KiB