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
84 ; With no load to trigger UB from poison, we cannot infer nsw.
94 %index32 = add nsw i32 %i, %offset
106 ; it should not infer nsw in this case, as that would require looking
119 %index32 = add nsw i32 %i, %offset
122 %nexti = add nsw i32 %i, 1
140 ; CHECK: --> {%offset,+,1}<nsw>
141 %index32 = add nsw i32 %i, %offset
144 %nexti = add nsw i32 %i, 1
166 %index32 = add nsw i32 %i, %offset
169 %nexti = add nsw i32 %i, 1
190 ; CHECK: --> {%offset,+,1}<nsw>
191 %index32 = add nsw i32 %i, %offset
194 %nexti = add nsw i32 %i, 1
218 %index32 = add nsw i32 %i, %offset
221 %nexti = add nsw i32 %i, 1
241 %index32 = add nsw i32 %i, %offset
244 %nexti = add nsw i32 %i, 1
263 %index32 = add nsw i32 %i, %offset
266 %nexti = add nsw i32 %i, 1
286 %index32 = add nsw i32 %i, %offset
289 %nexti = add nsw i32 %i, 1
298 ; a nuw or nsw flag on the multiplication.
307 ; CHECK: --> {%offset,+,1}<nsw>
308 %index32 = add nsw i32 %i, %offset
312 %nexti = add nsw i32 %i, 1
331 %index32 = add nsw i32 %i, %offset
333 %indexmul = mul nsw i32 %index32, %offset
335 %nexti = add nsw i32 %i, 1
354 %index32 = add nsw i32 %i, %offset
358 %nexti = add nsw i32 %i, 1
375 ; CHECK: --> {%offset,+,1}<nsw>
376 %j = add nsw i32 %i, %offset
379 %nexti = add nsw i32 %i, 1
396 %j = add nsw i32 %i, %offset
399 %nexti = add nsw i32 %i, 1
415 ; CHECK: --> {%offset,+,1}<nsw>
416 %index32 = add nsw i32 %i, %offset
419 %nexti = add nsw i32 %i, 1
427 ; Three sequential adds where the middle add should have nsw. There is
438 %seq = add nsw nuw i32 %index32, 1
445 %j = add nsw i32 %i, 1
447 ; CHECK: --> {(1 + %offset)<nsw>,+,1}<nsw>
448 %index32 = add nsw i32 %j, %offset
451 %nexti = add nsw i32 %i, 1
458 ; Example where a mul should get the nsw flag, so that a sext can be
460 define void @test-mul-nsw(float* %input, i32 %stride, i32 %numIterations) {
461 ; CHECK-LABEL: @test-mul-nsw
468 ; CHECK: --> {0,+,%stride}<nsw>
469 %index32 = mul nsw i32 %i, %stride
472 ; CHECK: --> {0,+,(sext i32 %stride to i64)}<nsw>
476 %nexti = add nsw i32 %i, 1
506 ; Example where a shl should get the nsw flag, so that a sext can be
508 define void @test-shl-nsw(float* %input, i32 %start, i32 %numIterations) {
509 ; CHECK-LABEL: @test-shl-nsw
516 ; CHECK: --> {(256 * %start),+,256}<nsw>
517 %index32 = shl nsw i32 %i, 8
520 ; CHECK: --> {(sext i32 (256 * %start) to i64),+,256}<nsw>
524 %nexti = add nsw i32 %i, 1
554 ; Example where a sub should *not* get the nsw flag, because of how
557 define void @test-sub-no-nsw(float* %input, i32 %start, i32 %sub, i32 %numIterations) {
558 ; CHECK-LABEL: @test-sub-no-nsw
566 %index32 = sub nsw i32 %i, %sub
570 %nexti = add nsw i32 %i, 1
578 ; Example where a sub should get the nsw flag as the RHS cannot be the
580 define void @test-sub-nsw(float* %input, i32 %start, i32 %sub, i32 %numIterations) {
581 ; CHECK-LABEL: @test-sub-nsw
589 ; CHECK: --> {((-1 * %halfsub)<nsw> + %start)<nsw>,+,1}<nsw>
590 %index32 = sub nsw i32 %i, %halfsub
594 %nexti = add nsw i32 %i, 1
602 ; Example where a sub should get the nsw flag, since the LHS is non-negative,
604 define void @test-sub-nsw-lhs-non-negative(float* %input, i32 %sub, i32 %numIterations) {
605 ; CHECK-LABEL: @test-sub-nsw-lhs-non-negative
612 ; CHECK: --> {(-1 * %sub),+,1}<nsw>
613 %index32 = sub nsw i32 %i, %sub
616 ; CHECK: --> {(sext i32 (-1 * %sub) to i64),+,1}<nsw>
620 %nexti = add nsw i32 %i, 1
628 ; Two adds with a sub in the middle and the sub should have nsw. There is
639 %seq = add nsw nuw i32 %index32, 1
646 %j = add nsw i32 %i, 1
648 ; CHECK: --> {(1 + (-1 * %offset))<nsw>,+,1}<nsw>
649 %index32 = sub nsw i32 %j, %offset
652 %nexti = add nsw i32 %i, 1
670 %o_idx.inc = add nsw i32 %o_idx, 1
676 %i_idx.inc = add nsw i32 %i_idx, 1
678 ; CHECK-NEXT: --> {{[{][{]}}-1,+,-1}<nw><%outer>,+,1}<nsw><%inner>
679 %v = sub nsw i32 %i_idx, %o_idx.inc