brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.8 KiB · e6e48d3 Raw
151 lines · plain
1// RUN: mlir-opt -int-range-optimizations --split-input-file %s | FileCheck %s2 3// CHECK-LABEL: func @test4//       CHECK:   %[[C:.*]] = arith.constant false5//       CHECK:   return %[[C]]6func.func @test() -> i1 {7  %cst1 = arith.constant -1 : index8  %0 = test.with_bounds { umin = 0 : index, umax = 0x7fffffffffffffff : index, smin = 0 : index, smax = 0x7fffffffffffffff : index } : index9  %1 = arith.cmpi eq, %0, %cst1 : index10  return %1: i111}12 13// -----14 15// CHECK-LABEL: func @test16//       CHECK:   %[[C:.*]] = arith.constant true17//       CHECK:   return %[[C]]18func.func @test() -> i1 {19  %cst1 = arith.constant -1 : index20  %0 = test.with_bounds { umin = 0 : index, umax = 0x7fffffffffffffff : index, smin = 0 : index, smax = 0x7fffffffffffffff : index } : index21  %1 = arith.cmpi ne, %0, %cst1 : index22  return %1: i123}24 25// -----26 27 28// CHECK-LABEL: func @test29//       CHECK:   %[[C:.*]] = arith.constant true30//       CHECK:   return %[[C]]31func.func @test() -> i1 {32  %cst = arith.constant 0 : index33  %0 = test.with_bounds { umin = 0 : index, umax = 0x7fffffffffffffff : index, smin = 0 : index, smax = 0x7fffffffffffffff : index } : index34  %1 = arith.cmpi sge, %0, %cst : index35  return %1: i136}37 38// -----39 40// CHECK-LABEL: func @test41//       CHECK:   %[[C:.*]] = arith.constant false42//       CHECK:   return %[[C]]43func.func @test() -> i1 {44  %cst = arith.constant 0 : index45  %0 = test.with_bounds { umin = 0 : index, umax = 0x7fffffffffffffff : index, smin = 0 : index, smax = 0x7fffffffffffffff : index } : index46  %1 = arith.cmpi slt, %0, %cst : index47  return %1: i148}49 50// -----51 52 53// CHECK-LABEL: func @test54//       CHECK:   %[[C:.*]] = arith.constant true55//       CHECK:   return %[[C]]56func.func @test() -> i1 {57  %cst1 = arith.constant -1 : index58  %0 = test.with_bounds { umin = 0 : index, umax = 0x7fffffffffffffff : index, smin = 0 : index, smax = 0x7fffffffffffffff : index } : index59  %1 = arith.cmpi sgt, %0, %cst1 : index60  return %1: i161}62 63// -----64 65// CHECK-LABEL: func @test66//       CHECK:   %[[C:.*]] = arith.constant false67//       CHECK:   return %[[C]]68func.func @test() -> i1 {69  %cst1 = arith.constant -1 : index70  %0 = test.with_bounds { umin = 0 : index, umax = 0x7fffffffffffffff : index, smin = 0 : index, smax = 0x7fffffffffffffff : index } : index71  %1 = arith.cmpi sle, %0, %cst1 : index72  return %1: i173}74 75// -----76 77// CHECK-LABEL: func @test78// CHECK: test.reflect_bounds {smax = 24 : si8, smin = 0 : si8, umax = 24 : ui8, umin = 0 : ui8}79func.func @test() -> i8 {80  %cst1 = arith.constant 1 : i881  %i8val = test.with_bounds { umin = 0 : i8, umax = 12 : i8, smin = 0 : i8, smax = 12 : i8 } : i882  %shifted = arith.shli %i8val, %cst1 : i883  %1 = test.reflect_bounds %shifted : i884  return %1: i885}86 87// -----88 89// CHECK-LABEL: func @test90// CHECK: test.reflect_bounds {smax = 127 : si8, smin = -128 : si8, umax = 254 : ui8, umin = 0 : ui8}91func.func @test() -> i8 {92  %cst1 = arith.constant 1 : i893  %i8val = test.with_bounds { umin = 0 : i8, umax = 127 : i8, smin = 0 : i8, smax = 127 : i8 } : i894  %shifted = arith.shli %i8val, %cst1 : i895  %1 = test.reflect_bounds %shifted : i896  return %1: i897}98 99// -----100 101// CHECK-LABEL: func @trivial_rem102// CHECK: [[val:%.+]] = test.with_bounds103// CHECK: return [[val]]104func.func @trivial_rem() -> i8 {105  %c64 = arith.constant 64 : i8106  %val = test.with_bounds { umin = 0 : ui8, umax = 63 : ui8, smin = 0 : si8, smax = 63 : si8 } : i8107  %mod = arith.remsi %val, %c64 : i8108  return %mod : i8109}110 111// -----112 113// CHECK-LABEL: func @non_const_rhs114// CHECK: [[mod:%.+]] = arith.remui115// CHECK: return [[mod]]116func.func @non_const_rhs() -> i8 {117  %c64 = arith.constant 64 : i8118  %val = test.with_bounds { umin = 0 : ui8, umax = 2 : ui8, smin = 0 : si8, smax = 2 : si8 } : i8119  %rhs = test.with_bounds { umin = 63 : ui8, umax = 64 : ui8, smin = 63 : si8, smax = 64 : si8 } : i8120  %mod = arith.remui %val, %rhs : i8121  return %mod : i8122}123 124// -----125 126// CHECK-LABEL: func @wraps127// CHECK: [[mod:%.+]] = arith.remsi128// CHECK: return [[mod]]129func.func @wraps() -> i8 {130  %c64 = arith.constant 64 : i8131  %val = test.with_bounds { umin = 63 : ui8, umax = 65 : ui8, smin = 63 : si8, smax = 65 : si8 } : i8132  %mod = arith.remsi %val, %c64 : i8133  return %mod : i8134}135 136// -----137 138// CHECK-LABEL: @analysis_crash139func.func @analysis_crash(%arg0: i32, %arg1: tensor<128xi1>) -> tensor<128xi64> {140  %c0_i32 = arith.constant 0 : i32141  %cst = arith.constant dense<-1> : tensor<128xi32>142  %splat = tensor.splat %arg0 : tensor<128xi32>143  %0 = scf.for %arg2 = %c0_i32 to %arg0 step %arg0 iter_args(%arg3 = %splat) -> (tensor<128xi32>)  : i32 {144    scf.yield %arg3 : tensor<128xi32>145  }146  %1 = arith.select %arg1, %0#0, %cst : tensor<128xi1>, tensor<128xi32>147  // Make sure the analysis doesn't crash when materializing the range as a tensor constant.148  %2 = arith.extsi %1 : tensor<128xi32> to tensor<128xi64>149  return %2 : tensor<128xi64>150}151