1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py 2; RUN: opt -S -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s 3 4; TODO: Make sure that zext(umin(x, y)) has same SCEV as umin(zext(x), zext(y)). 5; Equality proof: https://alive2.llvm.org/ce/z/vdsvmp 6define i1 @test_umin(i32 %x, i32 %y) { 7; CHECK-LABEL: 'test_umin' 8; CHECK-NEXT: Classifying expressions for: @test_umin 9; CHECK-NEXT: %umin_x_y = select i1 %cmp_x_y, i32 %x, i32 %y 10; CHECK-NEXT: --> (%x umin %y) U: full-set S: full-set 11; CHECK-NEXT: %zext_umin_x_y = zext i32 %umin_x_y to i64 12; CHECK-NEXT: --> ((zext i32 %x to i64) umin (zext i32 %y to i64)) U: [0,4294967296) S: [0,4294967296) 13; CHECK-NEXT: %zext_x = zext i32 %x to i64 14; CHECK-NEXT: --> (zext i32 %x to i64) U: [0,4294967296) S: [0,4294967296) 15; CHECK-NEXT: %zext_y = zext i32 %y to i64 16; CHECK-NEXT: --> (zext i32 %y to i64) U: [0,4294967296) S: [0,4294967296) 17; CHECK-NEXT: %umin_zext_x_zext_y = select i1 %cmp_zext_x_zext_y, i64 %zext_x, i64 %zext_y 18; CHECK-NEXT: --> ((zext i32 %x to i64) umin (zext i32 %y to i64)) U: [0,4294967296) S: [0,4294967296) 19; CHECK-NEXT: Determining loop execution counts for: @test_umin 20; 21 %cmp_x_y = icmp ult i32 %x, %y 22 %umin_x_y = select i1 %cmp_x_y, i32 %x, i32 %y 23 %zext_umin_x_y = zext i32 %umin_x_y to i64 24 25 %zext_x = zext i32 %x to i64 26 %zext_y = zext i32 %y to i64 27 %cmp_zext_x_zext_y = icmp ult i64 %zext_x, %zext_y 28 %umin_zext_x_zext_y = select i1 %cmp_zext_x_zext_y, i64 %zext_x, i64 %zext_y 29 30 %they_are_same = icmp eq i64 %zext_umin_x_y, %umin_zext_x_zext_y 31 ret i1 %they_are_same 32} 33 34; TODO: Make sure that zext(umax(x, y)) has same SCEV as umax(zext(x), zext(y)). 35; Equality proof: https://alive2.llvm.org/ce/z/5JHgxZ 36define i1 @test_umax(i32 %x, i32 %y) { 37; CHECK-LABEL: 'test_umax' 38; CHECK-NEXT: Classifying expressions for: @test_umax 39; CHECK-NEXT: %umax_x_y = select i1 %cmp_x_y, i32 %y, i32 %x 40; CHECK-NEXT: --> (%x umax %y) U: full-set S: full-set 41; CHECK-NEXT: %zext_umax_x_y = zext i32 %umax_x_y to i64 42; CHECK-NEXT: --> ((zext i32 %x to i64) umax (zext i32 %y to i64)) U: [0,4294967296) S: [0,4294967296) 43; CHECK-NEXT: %zext_x = zext i32 %x to i64 44; CHECK-NEXT: --> (zext i32 %x to i64) U: [0,4294967296) S: [0,4294967296) 45; CHECK-NEXT: %zext_y = zext i32 %y to i64 46; CHECK-NEXT: --> (zext i32 %y to i64) U: [0,4294967296) S: [0,4294967296) 47; CHECK-NEXT: %umax_zext_x_zext_y = select i1 %cmp_zext_x_zext_y, i64 %zext_y, i64 %zext_x 48; CHECK-NEXT: --> ((zext i32 %x to i64) umax (zext i32 %y to i64)) U: [0,4294967296) S: [0,4294967296) 49; CHECK-NEXT: Determining loop execution counts for: @test_umax 50; 51 %cmp_x_y = icmp ult i32 %x, %y 52 %umax_x_y = select i1 %cmp_x_y, i32 %y, i32 %x 53 %zext_umax_x_y = zext i32 %umax_x_y to i64 54 55 %zext_x = zext i32 %x to i64 56 %zext_y = zext i32 %y to i64 57 %cmp_zext_x_zext_y = icmp ult i64 %zext_x, %zext_y 58 %umax_zext_x_zext_y = select i1 %cmp_zext_x_zext_y, i64 %zext_y, i64 %zext_x 59 60 %they_are_same = icmp eq i64 %zext_umax_x_y, %umax_zext_x_zext_y 61 ret i1 %they_are_same 62} 63 64; TODO: Make sure that sext(smin(x, y)) has same SCEV as smin(sext(x), sext(y)). 65; Equality proof: https://alive2.llvm.org/ce/z/HhYHzR 66define i1 @test_smin(i32 %x, i32 %y) { 67; CHECK-LABEL: 'test_smin' 68; CHECK-NEXT: Classifying expressions for: @test_smin 69; CHECK-NEXT: %smin_x_y = select i1 %cmp_x_y, i32 %x, i32 %y 70; CHECK-NEXT: --> (%x smin %y) U: full-set S: full-set 71; CHECK-NEXT: %sext_smin_x_y = sext i32 %smin_x_y to i64 72; CHECK-NEXT: --> ((sext i32 %x to i64) smin (sext i32 %y to i64)) U: [-2147483648,2147483648) S: [-2147483648,2147483648) 73; CHECK-NEXT: %sext_x = sext i32 %x to i64 74; CHECK-NEXT: --> (sext i32 %x to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) 75; CHECK-NEXT: %sext_y = sext i32 %y to i64 76; CHECK-NEXT: --> (sext i32 %y to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) 77; CHECK-NEXT: %smin_sext_x_sext_y = select i1 %cmp_sext_x_sext_y, i64 %sext_x, i64 %sext_y 78; CHECK-NEXT: --> ((sext i32 %x to i64) smin (sext i32 %y to i64)) U: [-2147483648,2147483648) S: [-2147483648,2147483648) 79; CHECK-NEXT: Determining loop execution counts for: @test_smin 80; 81 %cmp_x_y = icmp slt i32 %x, %y 82 %smin_x_y = select i1 %cmp_x_y, i32 %x, i32 %y 83 %sext_smin_x_y = sext i32 %smin_x_y to i64 84 85 %sext_x = sext i32 %x to i64 86 %sext_y = sext i32 %y to i64 87 %cmp_sext_x_sext_y = icmp slt i64 %sext_x, %sext_y 88 %smin_sext_x_sext_y = select i1 %cmp_sext_x_sext_y, i64 %sext_x, i64 %sext_y 89 90 %they_are_same = icmp eq i64 %sext_smin_x_y, %smin_sext_x_sext_y 91 ret i1 %they_are_same 92} 93 94; TODO: Make sure that sext(smax(x, y)) has same SCEV as smax(sext(x), sext(y)). 95; Equality proof: https://alive2.llvm.org/ce/z/uou_u- 96define i1 @test_smax(i32 %x, i32 %y) { 97; CHECK-LABEL: 'test_smax' 98; CHECK-NEXT: Classifying expressions for: @test_smax 99; CHECK-NEXT: %smax_x_y = select i1 %cmp_x_y, i32 %y, i32 %x 100; CHECK-NEXT: --> (%x smax %y) U: full-set S: full-set 101; CHECK-NEXT: %sext_smax_x_y = sext i32 %smax_x_y to i64 102; CHECK-NEXT: --> ((sext i32 %x to i64) smax (sext i32 %y to i64)) U: [-2147483648,2147483648) S: [-2147483648,2147483648) 103; CHECK-NEXT: %sext_x = sext i32 %x to i64 104; CHECK-NEXT: --> (sext i32 %x to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) 105; CHECK-NEXT: %sext_y = sext i32 %y to i64 106; CHECK-NEXT: --> (sext i32 %y to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) 107; CHECK-NEXT: %smax_sext_x_sext_y = select i1 %cmp_sext_x_sext_y, i64 %sext_y, i64 %sext_x 108; CHECK-NEXT: --> ((sext i32 %x to i64) smax (sext i32 %y to i64)) U: [-2147483648,2147483648) S: [-2147483648,2147483648) 109; CHECK-NEXT: Determining loop execution counts for: @test_smax 110; 111 %cmp_x_y = icmp slt i32 %x, %y 112 %smax_x_y = select i1 %cmp_x_y, i32 %y, i32 %x 113 %sext_smax_x_y = sext i32 %smax_x_y to i64 114 115 %sext_x = sext i32 %x to i64 116 %sext_y = sext i32 %y to i64 117 %cmp_sext_x_sext_y = icmp slt i64 %sext_x, %sext_y 118 %smax_sext_x_sext_y = select i1 %cmp_sext_x_sext_y, i64 %sext_y, i64 %sext_x 119 120 %they_are_same = icmp eq i64 %sext_smax_x_y, %smax_sext_x_sext_y 121 ret i1 %they_are_same 122} 123 124; TODO: Make sure that zext(umin_seq(x, y)) has same SCEV as umin_seq(zext(x), zext(y)). 125; Equality proof: https://alive2.llvm.org/ce/z/X8kaNx 126define i1 @test_umin_seq(i1 %x, i1 %y) { 127; CHECK-LABEL: 'test_umin_seq' 128; CHECK-NEXT: Classifying expressions for: @test_umin_seq 129; CHECK-NEXT: %x_umin_seq_y = select i1 %x, i1 %y, i1 false 130; CHECK-NEXT: --> (%x umin_seq %y) U: full-set S: full-set 131; CHECK-NEXT: %zext_x_umin_seq_y = zext i1 %x_umin_seq_y to i64 132; CHECK-NEXT: --> ((zext i1 %x to i64) umin_seq (zext i1 %y to i64)) U: [0,2) S: [0,2) 133; CHECK-NEXT: %zext_x = zext i1 %x to i64 134; CHECK-NEXT: --> (zext i1 %x to i64) U: [0,2) S: [0,2) 135; CHECK-NEXT: %zext_y = zext i1 %y to i64 136; CHECK-NEXT: --> (zext i1 %y to i64) U: [0,2) S: [0,2) 137; CHECK-NEXT: %umin_zext_x_zext_y = select i1 %cmp_zext_x_zext_y, i64 %zext_x, i64 %zext_y 138; CHECK-NEXT: --> ((zext i1 %x to i64) umin (zext i1 %y to i64)) U: [0,2) S: [0,2) 139; CHECK-NEXT: %umin_seq_zext_x_xext_y = select i1 %zext_x_is_0, i64 0, i64 %umin_zext_x_zext_y 140; CHECK-NEXT: --> ((zext i1 %x to i64) umin_seq (zext i1 %y to i64)) U: [0,2) S: [0,2) 141; CHECK-NEXT: Determining loop execution counts for: @test_umin_seq 142; 143 %x_umin_seq_y = select i1 %x, i1 %y, i1 false 144 %zext_x_umin_seq_y = zext i1 %x_umin_seq_y to i64 145 146 %zext_x = zext i1 %x to i64 147 %zext_y = zext i1 %y to i64 148 %zext_x_is_0 = icmp eq i64 %zext_x, 0 149 %cmp_zext_x_zext_y = icmp ult i64 %zext_x, %zext_y 150 %umin_zext_x_zext_y = select i1 %cmp_zext_x_zext_y, i64 %zext_x, i64 %zext_y 151 %umin_seq_zext_x_xext_y = select i1 %zext_x_is_0, i64 0, i64 %umin_zext_x_zext_y 152 153 %they_are_same = icmp eq i64 %zext_x_umin_seq_y, %umin_seq_zext_x_xext_y 154 ret i1 %they_are_same 155} 156