`getelementptr nusw` semantics question

The property you have here is that the add between base.off and idx is nusw. In general, this implies neither nuw, nor nsw. If you know that idx is non-negative (or the original GEP is nuw) then you can infer nuw.

Some examples to illustrate:

  • Consider base.off=0x7fffffff, idx=1. Adding these is nuw, but not nsw.
  • Consider base.off=1, idx=-1. Adding these is nsw, but not nuw.

Both are nusw (i.e., no wrap if we interpret the LHS as unsigned and RHS as signed).