1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt < %s -analyze -enable-new-pm=0 -scalar-evolution | FileCheck %s
3 ; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
5 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64"
7 ; Collection of cases exercising range logic, mostly (but not exclusively)
8 ; involving SCEVUnknowns.
10 declare void @llvm.assume(i1)
12 define i32 @ashr(i32 %a) {
14 ; CHECK-NEXT: Classifying expressions for: @ashr
15 ; CHECK-NEXT: %ashr = ashr i32 %a, 31
16 ; CHECK-NEXT: --> %ashr U: [0,1) S: [0,1)
17 ; CHECK-NEXT: Determining loop execution counts for: @ashr
19 %ashr = ashr i32 %a, 31
20 %pos = icmp sge i32 %a, 0
21 call void @llvm.assume(i1 %pos)
25 ; Highlight the fact that non-argument non-instructions are
27 @G = external global i8
28 define i64 @ashr_global() {
29 ; CHECK-LABEL: 'ashr_global'
30 ; CHECK-NEXT: Classifying expressions for: @ashr_global
31 ; CHECK-NEXT: %ashr = ashr i64 ptrtoint (i8* @G to i64), 63
32 ; CHECK-NEXT: --> %ashr U: [-1,1) S: [-1,1)
33 ; CHECK-NEXT: Determining loop execution counts for: @ashr_global
35 %ashr = ashr i64 ptrtoint (i8* @G to i64), 63
36 %pos = icmp sge i8* @G, null
37 call void @llvm.assume(i1 %pos)
42 define i32 @shl(i32 %a) {
44 ; CHECK-NEXT: Classifying expressions for: @shl
45 ; CHECK-NEXT: %res = shl i32 %a, 2
46 ; CHECK-NEXT: --> (4 * %a) U: [0,-3) S: [-2147483648,2147483645)
47 ; CHECK-NEXT: Determining loop execution counts for: @shl
50 %pos = icmp ult i32 %a, 1024
51 call void @llvm.assume(i1 %pos)
55 define i32 @lshr(i32 %a) {
57 ; CHECK-NEXT: Classifying expressions for: @lshr
58 ; CHECK-NEXT: %res = lshr i32 %a, 31
59 ; CHECK-NEXT: --> (%a /u -2147483648) U: [0,2) S: [0,2)
60 ; CHECK-NEXT: Determining loop execution counts for: @lshr
62 %res = lshr i32 %a, 31
63 %pos = icmp sge i32 %a, 0
64 call void @llvm.assume(i1 %pos)
69 define i32 @udiv(i32 %a) {
71 ; CHECK-NEXT: Classifying expressions for: @udiv
72 ; CHECK-NEXT: %res = udiv i32 %a, -2147483648
73 ; CHECK-NEXT: --> (%a /u -2147483648) U: [0,2) S: [0,2)
74 ; CHECK-NEXT: Determining loop execution counts for: @udiv
76 %res = udiv i32 %a, 2147483648
77 %pos = icmp sge i32 %a, 0
78 call void @llvm.assume(i1 %pos)
82 define i64 @sext(i8 %a) {
84 ; CHECK-NEXT: Classifying expressions for: @sext
85 ; CHECK-NEXT: %res = sext i8 %a to i64
86 ; CHECK-NEXT: --> (sext i8 %a to i64) U: [-128,128) S: [-128,128)
87 ; CHECK-NEXT: Determining loop execution counts for: @sext
89 %res = sext i8 %a to i64
90 %pos = icmp sge i8 %a, 0
91 call void @llvm.assume(i1 %pos)
95 define i64 @zext(i8 %a) {
97 ; CHECK-NEXT: Classifying expressions for: @zext
98 ; CHECK-NEXT: %res = zext i8 %a to i64
99 ; CHECK-NEXT: --> (zext i8 %a to i64) U: [0,256) S: [0,256)
100 ; CHECK-NEXT: Determining loop execution counts for: @zext
102 %res = zext i8 %a to i64
103 %pos = icmp sge i8 %a, 0
104 call void @llvm.assume(i1 %pos)