Having %core.wrap.sub %core.mode.nuw (offset, %core.conv.u size 1:%core.I64); in the code, Thorin normalizes this to an addition with the value size - 1.
E.g. with size being 1024, this is normalized to %core.wrap.add 1024 2 (1023:(.Idx 1024), offset_123465);.
Since this makes explicit use of wrapping, this contradicts the wrap mode of no unsigned wrap -> LLVM interprets the generated instruction as a no-op and plain removes it:
%_123431 = add nuw i10 1023, %offset_123426
-> don't do this normalization if the wrap mode is not 0
Having
%core.wrap.sub %core.mode.nuw (offset, %core.conv.u size 1:%core.I64);
in the code, Thorin normalizes this to an addition with the valuesize - 1
. E.g. withsize
being1024
, this is normalized to%core.wrap.add 1024 2 (1023:(.Idx 1024), offset_123465);
. Since this makes explicit use of wrapping, this contradicts the wrap mode of no unsigned wrap -> LLVM interprets the generated instruction as a no-op and plain removes it:%_123431 = add nuw i10 1023, %offset_123426
-> don't do this normalization if the wrap mode is not 0