156 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py2; RUN: opt -S -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s3 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/vdsvmp6define i1 @test_umin(i32 %x, i32 %y) {7; CHECK-LABEL: 'test_umin'8; CHECK-NEXT: Classifying expressions for: @test_umin9; CHECK-NEXT: %umin_x_y = select i1 %cmp_x_y, i32 %x, i32 %y10; CHECK-NEXT: --> (%x umin %y) U: full-set S: full-set11; CHECK-NEXT: %zext_umin_x_y = zext i32 %umin_x_y to i6412; 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 i6414; CHECK-NEXT: --> (zext i32 %x to i64) U: [0,4294967296) S: [0,4294967296)15; CHECK-NEXT: %zext_y = zext i32 %y to i6416; 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_y18; 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_umin20;21 %cmp_x_y = icmp ult i32 %x, %y22 %umin_x_y = select i1 %cmp_x_y, i32 %x, i32 %y23 %zext_umin_x_y = zext i32 %umin_x_y to i6424 25 %zext_x = zext i32 %x to i6426 %zext_y = zext i32 %y to i6427 %cmp_zext_x_zext_y = icmp ult i64 %zext_x, %zext_y28 %umin_zext_x_zext_y = select i1 %cmp_zext_x_zext_y, i64 %zext_x, i64 %zext_y29 30 %they_are_same = icmp eq i64 %zext_umin_x_y, %umin_zext_x_zext_y31 ret i1 %they_are_same32}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/5JHgxZ36define i1 @test_umax(i32 %x, i32 %y) {37; CHECK-LABEL: 'test_umax'38; CHECK-NEXT: Classifying expressions for: @test_umax39; CHECK-NEXT: %umax_x_y = select i1 %cmp_x_y, i32 %y, i32 %x40; CHECK-NEXT: --> (%x umax %y) U: full-set S: full-set41; CHECK-NEXT: %zext_umax_x_y = zext i32 %umax_x_y to i6442; 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 i6444; CHECK-NEXT: --> (zext i32 %x to i64) U: [0,4294967296) S: [0,4294967296)45; CHECK-NEXT: %zext_y = zext i32 %y to i6446; 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_x48; 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_umax50;51 %cmp_x_y = icmp ult i32 %x, %y52 %umax_x_y = select i1 %cmp_x_y, i32 %y, i32 %x53 %zext_umax_x_y = zext i32 %umax_x_y to i6454 55 %zext_x = zext i32 %x to i6456 %zext_y = zext i32 %y to i6457 %cmp_zext_x_zext_y = icmp ult i64 %zext_x, %zext_y58 %umax_zext_x_zext_y = select i1 %cmp_zext_x_zext_y, i64 %zext_y, i64 %zext_x59 60 %they_are_same = icmp eq i64 %zext_umax_x_y, %umax_zext_x_zext_y61 ret i1 %they_are_same62}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/HhYHzR66define i1 @test_smin(i32 %x, i32 %y) {67; CHECK-LABEL: 'test_smin'68; CHECK-NEXT: Classifying expressions for: @test_smin69; CHECK-NEXT: %smin_x_y = select i1 %cmp_x_y, i32 %x, i32 %y70; CHECK-NEXT: --> (%x smin %y) U: full-set S: full-set71; CHECK-NEXT: %sext_smin_x_y = sext i32 %smin_x_y to i6472; 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 i6474; CHECK-NEXT: --> (sext i32 %x to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)75; CHECK-NEXT: %sext_y = sext i32 %y to i6476; 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_y78; 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_smin80;81 %cmp_x_y = icmp slt i32 %x, %y82 %smin_x_y = select i1 %cmp_x_y, i32 %x, i32 %y83 %sext_smin_x_y = sext i32 %smin_x_y to i6484 85 %sext_x = sext i32 %x to i6486 %sext_y = sext i32 %y to i6487 %cmp_sext_x_sext_y = icmp slt i64 %sext_x, %sext_y88 %smin_sext_x_sext_y = select i1 %cmp_sext_x_sext_y, i64 %sext_x, i64 %sext_y89 90 %they_are_same = icmp eq i64 %sext_smin_x_y, %smin_sext_x_sext_y91 ret i1 %they_are_same92}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_smax99; CHECK-NEXT: %smax_x_y = select i1 %cmp_x_y, i32 %y, i32 %x100; CHECK-NEXT: --> (%x smax %y) U: full-set S: full-set101; CHECK-NEXT: %sext_smax_x_y = sext i32 %smax_x_y to i64102; 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 i64104; CHECK-NEXT: --> (sext i32 %x to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)105; CHECK-NEXT: %sext_y = sext i32 %y to i64106; 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_x108; 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_smax110;111 %cmp_x_y = icmp slt i32 %x, %y112 %smax_x_y = select i1 %cmp_x_y, i32 %y, i32 %x113 %sext_smax_x_y = sext i32 %smax_x_y to i64114 115 %sext_x = sext i32 %x to i64116 %sext_y = sext i32 %y to i64117 %cmp_sext_x_sext_y = icmp slt i64 %sext_x, %sext_y118 %smax_sext_x_sext_y = select i1 %cmp_sext_x_sext_y, i64 %sext_y, i64 %sext_x119 120 %they_are_same = icmp eq i64 %sext_smax_x_y, %smax_sext_x_sext_y121 ret i1 %they_are_same122}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/X8kaNx126define i1 @test_umin_seq(i1 %x, i1 %y) {127; CHECK-LABEL: 'test_umin_seq'128; CHECK-NEXT: Classifying expressions for: @test_umin_seq129; CHECK-NEXT: %x_umin_seq_y = select i1 %x, i1 %y, i1 false130; CHECK-NEXT: --> (%x umin_seq %y) U: full-set S: full-set131; CHECK-NEXT: %zext_x_umin_seq_y = zext i1 %x_umin_seq_y to i64132; 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 i64134; CHECK-NEXT: --> (zext i1 %x to i64) U: [0,2) S: [0,2)135; CHECK-NEXT: %zext_y = zext i1 %y to i64136; 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_y138; 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_y140; 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_seq142;143 %x_umin_seq_y = select i1 %x, i1 %y, i1 false144 %zext_x_umin_seq_y = zext i1 %x_umin_seq_y to i64145 146 %zext_x = zext i1 %x to i64147 %zext_y = zext i1 %y to i64148 %zext_x_is_0 = icmp eq i64 %zext_x, 0149 %cmp_zext_x_zext_y = icmp ult i64 %zext_x, %zext_y150 %umin_zext_x_zext_y = select i1 %cmp_zext_x_zext_y, i64 %zext_x, i64 %zext_y151 %umin_seq_zext_x_xext_y = select i1 %zext_x_is_0, i64 0, i64 %umin_zext_x_zext_y152 153 %they_are_same = icmp eq i64 %zext_x_umin_seq_y, %umin_seq_zext_x_xext_y154 ret i1 %they_are_same155}156