1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[NFC][SCEV] Some tests for shifts by bitwidth-2/bitwidth-1 w/ no-wrap flags

This commit is contained in:
Roman Lebedev 2020-06-05 11:23:16 +03:00
parent 1e0eace6d4
commit 12c3785b27

View File

@ -525,6 +525,106 @@ exit:
ret void
}
; Example where a shl should get the nuw flag
define void @test-shl-nuw-edgecase(float* %input, i32 %start, i32 %numIterations) {
; CHECK-LABEL: @test-shl-nuw-edgecase
entry:
br label %loop
loop:
%i = phi i32 [ %nexti, %loop ], [ %start, %entry ]
; CHECK: %index32 =
; CHECK: --> {(-2147483648 * %start),+,-2147483648}<%loop>
%index32 = shl nuw i32 %i, 31
; CHECK: %index64 =
; CHECK: --> (sext i32 {(-2147483648 * %start),+,-2147483648}<%loop>
%index64 = sext i32 %index32 to i64
%ptr = getelementptr inbounds float, float* %input, i64 %index64
%nexti = add nsw i32 %i, 1
%f = load float, float* %ptr, align 4
%exitcond = icmp eq i32 %nexti, %numIterations
br i1 %exitcond, label %exit, label %loop
exit:
ret void
}
; Example where a shl should get the nuw flag
define void @test-shl-nuw-nsw(float* %input, i32 %start, i32 %numIterations) {
; CHECK-LABEL: @test-shl-nuw-nsw
entry:
br label %loop
loop:
%i = phi i32 [ %nexti, %loop ], [ %start, %entry ]
; CHECK: %index32 =
; CHECK: --> {(-2147483648 * %start),+,-2147483648}<%loop>
%index32 = shl nuw nsw i32 %i, 31
; CHECK: %index64 =
; CHECK: --> (sext i32 {(-2147483648 * %start),+,-2147483648}<%loop>
%index64 = sext i32 %index32 to i64
%ptr = getelementptr inbounds float, float* %input, i64 %index64
%nexti = add nsw i32 %i, 1
%f = load float, float* %ptr, align 4
%exitcond = icmp eq i32 %nexti, %numIterations
br i1 %exitcond, label %exit, label %loop
exit:
ret void
}
; Example where a shl should not get the nsw flag
define void @test-shl-no-nsw(float* %input, i32 %start, i32 %numIterations) {
; CHECK-LABEL: @test-shl-no-nsw
entry:
br label %loop
loop:
%i = phi i32 [ %nexti, %loop ], [ %start, %entry ]
; CHECK: %index32 =
; CHECK: --> {(-2147483648 * %start),+,-2147483648}<%loop>
%index32 = shl nsw i32 %i, 31
; CHECK: %index64 =
; CHECK: --> (sext i32 {(-2147483648 * %start),+,-2147483648}<%loop>
%index64 = sext i32 %index32 to i64
%ptr = getelementptr inbounds float, float* %input, i64 %index64
%nexti = add nsw i32 %i, 1
%f = load float, float* %ptr, align 4
%exitcond = icmp eq i32 %nexti, %numIterations
br i1 %exitcond, label %exit, label %loop
exit:
ret void
}
; Example where a shl should get the nsw flag.
define void @test-shl-nsw-edgecase(float* %input, i32 %start, i32 %numIterations) {
; CHECK-LABEL: @test-shl-nsw-edgecase
entry:
br label %loop
loop:
%i = phi i32 [ %nexti, %loop ], [ %start, %entry ]
; CHECK: %index32 =
; CHECK: --> {(1073741824 * %start),+,1073741824}<nsw><%loop>
%index32 = shl nsw i32 %i, 30
; CHECK: %index64 =
; CHECK: --> {(sext i32 (1073741824 * %start) to i64),+,1073741824}<nsw><%loop>
%index64 = sext i32 %index32 to i64
%ptr = getelementptr inbounds float, float* %input, i64 %index64
%nexti = add nsw i32 %i, 1
%f = load float, float* %ptr, align 4
%exitcond = icmp eq i32 %nexti, %numIterations
br i1 %exitcond, label %exit, label %loop
exit:
ret void
}
; Example where a shl should get the nuw flag.
define void @test-shl-nuw(float* %input, i32 %numIterations) {
; CHECK-LABEL: @test-shl-nuw