Lines Matching refs:nsw

3 ; Positive and negative tests for inferring flags like nsw from
11 ; Example where an add should get the nsw flag, so that a sext can be
13 define void @test-add-nsw(float* %input, i32 %offset, i32 %numIterations) {
14 ; CHECK-LABEL: @test-add-nsw
21 ; CHECK: --> {%offset,+,1}<nsw>
22 %index32 = add nsw i32 %i, %offset
25 ; CHECK: --> {(sext i32 %offset to i64),+,1}<nsw>
29 %nexti = add nsw i32 %i, 1
60 ; With no load to trigger UB from poison, we cannot infer nsw.
70 %index32 = add nsw i32 %i, %offset
82 ; it should not infer nsw in this case, as that would require looking
95 %index32 = add nsw i32 %i, %offset
98 %nexti = add nsw i32 %i, 1
117 %index32 = add nsw i32 %i, %offset
120 %nexti = add nsw i32 %i, 1
143 %index32 = add nsw i32 %i, %offset
146 %nexti = add nsw i32 %i, 1
165 %index32 = add nsw i32 %i, %offset
168 %nexti = add nsw i32 %i, 1
188 %index32 = add nsw i32 %i, %offset
191 %nexti = add nsw i32 %i, 1
200 ; a nuw or nsw flag on the multiplication.
209 ; CHECK: --> {%offset,+,1}<nsw>
210 %index32 = add nsw i32 %i, %offset
214 %nexti = add nsw i32 %i, 1
233 %index32 = add nsw i32 %i, %offset
235 %indexmul = mul nsw i32 %index32, %offset
237 %nexti = add nsw i32 %i, 1
256 %index32 = add nsw i32 %i, %offset
260 %nexti = add nsw i32 %i, 1
277 ; CHECK: --> {%offset,+,1}<nsw>
278 %j = add nsw i32 %i, %offset
281 %nexti = add nsw i32 %i, 1
298 %j = add nsw i32 %i, %offset
301 %nexti = add nsw i32 %i, 1
317 ; CHECK: --> {%offset,+,1}<nsw>
318 %index32 = add nsw i32 %i, %offset
321 %nexti = add nsw i32 %i, 1
329 ; Three sequential adds where the middle add should have nsw. There is
340 %seq = add nsw nuw i32 %index32, 1
347 %j = add nsw i32 %i, 1
349 ; CHECK: --> {(1 + %offset),+,1}<nsw>
350 %index32 = add nsw i32 %j, %offset
353 %nexti = add nsw i32 %i, 1
360 ; Example where a mul should get the nsw flag, so that a sext can be
362 define void @test-mul-nsw(float* %input, i32 %stride, i32 %numIterations) {
363 ; CHECK-LABEL: @test-mul-nsw
370 ; CHECK: --> {0,+,%stride}<nsw>
371 %index32 = mul nsw i32 %i, %stride
374 ; CHECK: --> {0,+,(sext i32 %stride to i64)}<nsw>
378 %nexti = add nsw i32 %i, 1
408 ; Example where a shl should get the nsw flag, so that a sext can be
410 define void @test-shl-nsw(float* %input, i32 %start, i32 %numIterations) {
411 ; CHECK-LABEL: @test-shl-nsw
418 ; CHECK: --> {(256 * %start),+,256}<nsw>
419 %index32 = shl nsw i32 %i, 8
422 ; CHECK: --> {(sext i32 (256 * %start) to i64),+,256}<nsw>
426 %nexti = add nsw i32 %i, 1
456 ; Example where a sub should *not* get the nsw flag, because of how
459 define void @test-sub-no-nsw(float* %input, i32 %start, i32 %sub, i32 %numIterations) {
460 ; CHECK-LABEL: @test-sub-no-nsw
468 %index32 = sub nsw i32 %i, %sub
472 %nexti = add nsw i32 %i, 1
480 ; Example where a sub should get the nsw flag as the RHS cannot be the
482 define void @test-sub-nsw(float* %input, i32 %start, i32 %sub, i32 %numIterations) {
483 ; CHECK-LABEL: @test-sub-nsw
491 ; CHECK: --> {((-1 * %halfsub)<nsw> + %start),+,1}<nsw>
492 %index32 = sub nsw i32 %i, %halfsub
496 %nexti = add nsw i32 %i, 1
504 ; Example where a sub should get the nsw flag, since the LHS is non-negative,
506 define void @test-sub-nsw-lhs-non-negative(float* %input, i32 %sub, i32 %numIterations) {
507 ; CHECK-LABEL: @test-sub-nsw-lhs-non-negative
514 ; CHECK: --> {(-1 * %sub),+,1}<nsw>
515 %index32 = sub nsw i32 %i, %sub
518 ; CHECK: --> {(sext i32 (-1 * %sub) to i64),+,1}<nsw>
522 %nexti = add nsw i32 %i, 1
530 ; Two adds with a sub in the middle and the sub should have nsw. There is
541 %seq = add nsw nuw i32 %index32, 1
548 %j = add nsw i32 %i, 1
550 ; CHECK: --> {(1 + (-1 * %offset)),+,1}<nsw>
551 %index32 = sub nsw i32 %j, %offset
554 %nexti = add nsw i32 %i, 1
572 %o_idx.inc = add nsw i32 %o_idx, 1
578 %i_idx.inc = add nsw i32 %i_idx, 1
580 ; CHECK-NEXT: --> {{[{][{]}}-1,+,-1}<nw><%outer>,+,1}<nsw><%inner>
581 %v = sub nsw i32 %i_idx, %o_idx.inc