brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.0 KiB · 0ea69de Raw
117 lines · plain
1// RUN: mlir-opt -arith-unsigned-when-equivalent %s | FileCheck %s2 3// CHECK-LABEL: func @not_with_maybe_overflow4// CHECK: arith.divsi5// CHECK: arith.ceildivsi6// CHECK: arith.floordivsi7// CHECK: arith.remsi8// CHECK: arith.minsi9// CHECK: arith.maxsi10// CHECK: arith.extsi11// CHECK: arith.cmpi sle12// CHECK: arith.cmpi slt13// CHECK: arith.cmpi sge14// CHECK: arith.cmpi sgt15func.func @not_with_maybe_overflow(%arg0 : i32) -> (i32, i32, i32, i32, i32, i32, i64, i1, i1, i1, i1) {16    %ci32_smax = arith.constant 0x7fffffff : i3217    %c1 = arith.constant 1 : i3218    %c4 = arith.constant 4 : i3219    %0 = arith.minui %arg0, %ci32_smax : i3220    %1 = arith.addi %0, %c1 : i3221    %2 = arith.divsi %1, %c4 : i3222    %3 = arith.ceildivsi %1, %c4 : i3223    %4 = arith.floordivsi %1, %c4 : i3224    %5 = arith.remsi %1, %c4 : i3225    %6 = arith.minsi %1, %c4 : i3226    %7 = arith.maxsi %1, %c4 : i3227    %8 = arith.extsi %1 : i32 to i6428    %9 = arith.cmpi sle, %1, %c4 : i3229    %10 = arith.cmpi slt, %1, %c4 : i3230    %11 = arith.cmpi sge, %1, %c4 : i3231    %12 = arith.cmpi sgt, %1, %c4 : i3232    func.return %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12 : i32, i32, i32, i32, i32, i32, i64, i1, i1, i1, i133}34 35// CHECK-LABEL: func @yes_with_no_overflow36// CHECK: arith.divui37// CHECK: arith.ceildivui38// CHECK: arith.divui39// CHECK: arith.remui40// CHECK: arith.minui41// CHECK: arith.maxui42// CHECK: arith.extui43// CHECK: arith.cmpi ule44// CHECK: arith.cmpi ult45// CHECK: arith.cmpi uge46// CHECK: arith.cmpi ugt47func.func @yes_with_no_overflow(%arg0 : i32) -> (i32, i32, i32, i32, i32, i32, i64, i1, i1, i1, i1) {48    %ci32_almost_smax = arith.constant 0x7ffffffe : i3249    %c1 = arith.constant 1 : i3250    %c4 = arith.constant 4 : i3251    %0 = arith.minui %arg0, %ci32_almost_smax : i3252    %1 = arith.addi %0, %c1 : i3253    %2 = arith.divsi %1, %c4 : i3254    %3 = arith.ceildivsi %1, %c4 : i3255    %4 = arith.floordivsi %1, %c4 : i3256    %5 = arith.remsi %1, %c4 : i3257    %6 = arith.minsi %1, %c4 : i3258    %7 = arith.maxsi %1, %c4 : i3259    %8 = arith.extsi %1 : i32 to i6460    %9 = arith.cmpi sle, %1, %c4 : i3261    %10 = arith.cmpi slt, %1, %c4 : i3262    %11 = arith.cmpi sge, %1, %c4 : i3263    %12 = arith.cmpi sgt, %1, %c4 : i3264    func.return %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12 : i32, i32, i32, i32, i32, i32, i64, i1, i1, i1, i165}66 67// CHECK-LABEL: func @preserves_structure68// CHECK: scf.for %[[arg1:.*]] =69// CHECK: %[[v:.*]] = arith.remui %[[arg1]]70// CHECK: %[[w:.*]] = arith.addi %[[v]], %[[v]]71// CHECK: %[[test:.*]] = arith.cmpi ule, %[[w]]72// CHECK: scf.if %[[test]]73// CHECK: memref.store %[[w]]74func.func @preserves_structure(%arg0 : memref<8xindex>) {75    %c0 = arith.constant 0 : index76    %c1 = arith.constant 1 : index77    %c4 = arith.constant 4 : index78    %c8 = arith.constant 8 : index79    scf.for %arg1 = %c0 to %c8 step %c1 {80        %v = arith.remsi %arg1, %c4 : index81        %w = arith.addi %v, %v : index82        %test = arith.cmpi sle, %w, %c4 : index83        scf.if %test {84            memref.store %w, %arg0[%arg1] : memref<8xindex>85        }86    }87    func.return88}89 90func.func private @external() -> i891 92// CHECK-LABEL: @dead_code93func.func @dead_code() -> i8 {94  %0 = call @external() : () -> i895  // CHECK: arith.floordivsi96  %1 = arith.floordivsi %0, %0 : i897  return %1 : i898}99 100// Make sure not crash.101// CHECK-LABEL: @no_integer_or_index102func.func @no_integer_or_index(%arg0: vector<1xi32>) -> vector<1xi1> {103  // CHECK: arith.cmpi104  %cst_0 = arith.constant dense<[0]> : vector<1xi32> 105  %cmp = arith.cmpi slt, %cst_0, %arg0 : vector<1xi32>106  return %cmp : vector<1xi1>107}108 109// CHECK-LABEL: @gpu_func110func.func @gpu_func(%arg0: memref<2x32xf32>, %arg1: memref<2x32xf32>, %arg2: memref<32xf32>, %arg3: f32, %arg4: !gpu.async.token, %arg5: index, %arg6: index) -> memref<2x32xf32> {111  %c1 = arith.constant 1 : index  112  %2 = gpu.launch async [%arg4] blocks(%arg7, %arg8, %arg9) in (%arg13 = %c1, %arg14 = %c1, %arg15 = %c1) threads(%arg10, %arg11, %arg12) in (%arg16 = %c1, %arg17 = %c1, %arg18 = %c1) {113    gpu.terminator114  } 115  return %arg1 : memref<2x32xf32> 116}117