[llvm] 39e3c92 - [NFC][SCEV] Some tests for shifts by bitwidth-2/bitwidth-1 w/ no-wrap flags
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 5 01:45:40 PDT 2020
Author: Roman Lebedev
Date: 2020-06-05T11:45:09+03:00
New Revision: 39e3c92410d1877e31da2201dc92f559f040bfa9
URL: https://github.com/llvm/llvm-project/commit/39e3c92410d1877e31da2201dc92f559f040bfa9
DIFF: https://github.com/llvm/llvm-project/commit/39e3c92410d1877e31da2201dc92f559f040bfa9.diff
LOG: [NFC][SCEV] Some tests for shifts by bitwidth-2/bitwidth-1 w/ no-wrap flags
Added:
Modified:
llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll
Removed:
################################################################################
diff --git a/llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll b/llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll
index caf372f9ea91..2b60192b1fb2 100644
--- a/llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll
+++ b/llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll
@@ -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
More information about the llvm-commits
mailing list