1 ; RUN: opt -S -analyze -scalar-evolution < %s | FileCheck %s 2 3 !0 = !{i8 0, i8 127} 4 5 define void @f0(i8* %len_addr) { 6 ; CHECK-LABEL: Classifying expressions for: @f0 7 entry: 8 %len = load i8, i8* %len_addr, !range !0 9 %len_norange = load i8, i8* %len_addr 10 ; CHECK: %len = load i8, i8* %len_addr, !range !0 11 ; CHECK-NEXT: --> %len U: [0,127) S: [0,127) 12 ; CHECK: %len_norange = load i8, i8* %len_addr 13 ; CHECK-NEXT: --> %len_norange U: full-set S: full-set 14 15 %t0 = add i8 %len, 1 16 %t1 = add i8 %len, 2 17 ; CHECK: %t0 = add i8 %len, 1 18 ; CHECK-NEXT: --> (1 + %len)<nuw><nsw> U: [1,-128) S: [1,-128) 19 ; CHECK: %t1 = add i8 %len, 2 20 ; CHECK-NEXT: --> (2 + %len)<nuw> U: [2,-127) S: [2,-127) 21 22 %t2 = sub i8 %len, 1 23 %t3 = sub i8 %len, 2 24 ; CHECK: %t2 = sub i8 %len, 1 25 ; CHECK-NEXT: --> (-1 + %len)<nsw> U: [-1,126) S: [-1,126) 26 ; CHECK: %t3 = sub i8 %len, 2 27 ; CHECK-NEXT: --> (-2 + %len)<nsw> U: [-2,125) S: [-2,125) 28 29 %q0 = add i8 %len_norange, 1 30 %q1 = add i8 %len_norange, 2 31 ; CHECK: %q0 = add i8 %len_norange, 1 32 ; CHECK-NEXT: --> (1 + %len_norange) U: full-set S: full-set 33 ; CHECK: %q1 = add i8 %len_norange, 2 34 ; CHECK-NEXT: --> (2 + %len_norange) U: full-set S: full-set 35 36 %q2 = sub i8 %len_norange, 1 37 %q3 = sub i8 %len_norange, 2 38 ; CHECK: %q2 = sub i8 %len_norange, 1 39 ; CHECK-NEXT: --> (-1 + %len_norange) U: full-set S: full-set 40 ; CHECK: %q3 = sub i8 %len_norange, 2 41 ; CHECK-NEXT: --> (-2 + %len_norange) U: full-set S: full-set 42 43 ret void 44 } 45 46 define void @f1(i8* %len_addr) { 47 ; CHECK-LABEL: Classifying expressions for: @f1 48 entry: 49 %len = load i8, i8* %len_addr, !range !0 50 %len_norange = load i8, i8* %len_addr 51 ; CHECK: %len = load i8, i8* %len_addr, !range !0 52 ; CHECK-NEXT: --> %len U: [0,127) S: [0,127) 53 ; CHECK: %len_norange = load i8, i8* %len_addr 54 ; CHECK-NEXT: --> %len_norange U: full-set S: full-set 55 56 %t0 = add i8 %len, -1 57 %t1 = add i8 %len, -2 58 ; CHECK: %t0 = add i8 %len, -1 59 ; CHECK-NEXT: --> (-1 + %len)<nsw> U: [-1,126) S: [-1,126) 60 ; CHECK: %t1 = add i8 %len, -2 61 ; CHECK-NEXT: --> (-2 + %len)<nsw> U: [-2,125) S: [-2,125) 62 63 %t0.sext = sext i8 %t0 to i16 64 %t1.sext = sext i8 %t1 to i16 65 ; CHECK: %t0.sext = sext i8 %t0 to i16 66 ; CHECK-NEXT: --> (-1 + (zext i8 %len to i16))<nsw> U: [-1,126) S: [-1,126) 67 ; CHECK: %t1.sext = sext i8 %t1 to i16 68 ; CHECK-NEXT: --> (-2 + (zext i8 %len to i16))<nsw> U: [-2,125) S: [-2,125) 69 70 %q0 = add i8 %len_norange, 1 71 %q1 = add i8 %len_norange, 2 72 ; CHECK: %q0 = add i8 %len_norange, 1 73 ; CHECK-NEXT: --> (1 + %len_norange) U: full-set S: full-set 74 ; CHECK: %q1 = add i8 %len_norange, 2 75 ; CHECK-NEXT: --> (2 + %len_norange) U: full-set S: full-set 76 77 %q0.sext = sext i8 %q0 to i16 78 %q1.sext = sext i8 %q1 to i16 79 ; CHECK: %q0.sext = sext i8 %q0 to i16 80 ; CHECK-NEXT: --> (sext i8 (1 + %len_norange) to i16) U: [-128,128) S: [-128,128) 81 ; CHECK: %q1.sext = sext i8 %q1 to i16 82 ; CHECK-NEXT: --> (sext i8 (2 + %len_norange) to i16) U: [-128,128) S: [-128,128) 83 84 ret void 85 } 86 87 define void @f2(i8* %len_addr) { 88 ; CHECK-LABEL: Classifying expressions for: @f2 89 entry: 90 %len = load i8, i8* %len_addr, !range !0 91 %len_norange = load i8, i8* %len_addr 92 ; CHECK: %len = load i8, i8* %len_addr, !range !0 93 ; CHECK-NEXT: --> %len U: [0,127) S: [0,127) 94 ; CHECK: %len_norange = load i8, i8* %len_addr 95 ; CHECK-NEXT: --> %len_norange U: full-set S: full-set 96 97 %t0 = add i8 %len, 1 98 %t1 = add i8 %len, 2 99 ; CHECK: %t0 = add i8 %len, 1 100 ; CHECK-NEXT: --> (1 + %len)<nuw><nsw> 101 ; CHECK: %t1 = add i8 %len, 2 102 ; CHECK-NEXT: --> (2 + %len)<nuw> 103 104 %t0.zext = zext i8 %t0 to i16 105 %t1.zext = zext i8 %t1 to i16 106 ; CHECK: %t0.zext = zext i8 %t0 to i16 107 ; CHECK-NEXT: --> (1 + (zext i8 %len to i16))<nuw><nsw> U: [1,128) S: [1,128) 108 ; CHECK: %t1.zext = zext i8 %t1 to i16 109 ; CHECK-NEXT: --> (2 + (zext i8 %len to i16))<nuw><nsw> U: [2,129) S: [2,129) 110 111 %q0 = add i8 %len_norange, 1 112 %q1 = add i8 %len_norange, 2 113 %q0.zext = zext i8 %q0 to i16 114 %q1.zext = zext i8 %q1 to i16 115 116 ; CHECK: %q0.zext = zext i8 %q0 to i16 117 ; CHECK-NEXT: --> (zext i8 (1 + %len_norange) to i16) U: [0,256) S: [0,256) 118 ; CHECK: %q1.zext = zext i8 %q1 to i16 119 ; CHECK-NEXT: --> (zext i8 (2 + %len_norange) to i16) U: [0,256) S: [0,256) 120 121 ret void 122 } 123