1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
// RUN: mlir-opt -convert-spirv-to-llvm='use-opaque-pointers=1' %s | FileCheck %s
//===----------------------------------------------------------------------===//
// spirv.ShiftRightArithmetic
//===----------------------------------------------------------------------===//
// CHECK-LABEL: @shift_right_arithmetic_scalar
spirv.func @shift_right_arithmetic_scalar(%arg0: i32, %arg1: si32, %arg2 : i16, %arg3 : ui16) "None" {
// CHECK: llvm.ashr %{{.*}}, %{{.*}} : i32
%0 = spirv.ShiftRightArithmetic %arg0, %arg0 : i32, i32
// CHECK: llvm.ashr %{{.*}}, %{{.*}} : i32
%1 = spirv.ShiftRightArithmetic %arg0, %arg1 : i32, si32
// CHECK: %[[SEXT:.*]] = llvm.sext %{{.*}} : i16 to i32
// CHECK: llvm.ashr %{{.*}}, %[[SEXT]] : i32
%2 = spirv.ShiftRightArithmetic %arg0, %arg2 : i32, i16
// CHECK: %[[ZEXT:.*]] = llvm.zext %{{.*}} : i16 to i32
// CHECK: llvm.ashr %{{.*}}, %[[ZEXT]] : i32
%3 = spirv.ShiftRightArithmetic %arg0, %arg3 : i32, ui16
spirv.Return
}
// CHECK-LABEL: @shift_right_arithmetic_vector
spirv.func @shift_right_arithmetic_vector(%arg0: vector<4xi64>, %arg1: vector<4xui64>, %arg2: vector<4xi32>, %arg3: vector<4xui32>) "None" {
// CHECK: llvm.ashr %{{.*}}, %{{.*}} : vector<4xi64>
%0 = spirv.ShiftRightArithmetic %arg0, %arg0 : vector<4xi64>, vector<4xi64>
// CHECK: llvm.ashr %{{.*}}, %{{.*}} : vector<4xi64>
%1 = spirv.ShiftRightArithmetic %arg0, %arg1 : vector<4xi64>, vector<4xui64>
// CHECK: %[[SEXT:.*]] = llvm.sext %{{.*}} : vector<4xi32> to vector<4xi64>
// CHECK: llvm.ashr %{{.*}}, %[[SEXT]] : vector<4xi64>
%2 = spirv.ShiftRightArithmetic %arg0, %arg2 : vector<4xi64>, vector<4xi32>
// CHECK: %[[ZEXT:.*]] = llvm.zext %{{.*}} : vector<4xi32> to vector<4xi64>
// CHECK: llvm.ashr %{{.*}}, %[[ZEXT]] : vector<4xi64>
%3 = spirv.ShiftRightArithmetic %arg0, %arg3 : vector<4xi64>, vector<4xui32>
spirv.Return
}
//===----------------------------------------------------------------------===//
// spirv.ShiftRightLogical
//===----------------------------------------------------------------------===//
// CHECK-LABEL: @shift_right_logical_scalar
spirv.func @shift_right_logical_scalar(%arg0: i32, %arg1: si32, %arg2 : si16, %arg3 : ui16) "None" {
// CHECK: llvm.lshr %{{.*}}, %{{.*}} : i32
%0 = spirv.ShiftRightLogical %arg0, %arg0 : i32, i32
// CHECK: llvm.lshr %{{.*}}, %{{.*}} : i32
%1 = spirv.ShiftRightLogical %arg0, %arg1 : i32, si32
// CHECK: %[[SEXT:.*]] = llvm.sext %{{.*}} : i16 to i32
// CHECK: llvm.lshr %{{.*}}, %[[SEXT]] : i32
%2 = spirv.ShiftRightLogical %arg0, %arg2 : i32, si16
// CHECK: %[[ZEXT:.*]] = llvm.zext %{{.*}} : i16 to i32
// CHECK: llvm.lshr %{{.*}}, %[[ZEXT]] : i32
%3 = spirv.ShiftRightLogical %arg0, %arg3 : i32, ui16
spirv.Return
}
// CHECK-LABEL: @shift_right_logical_vector
spirv.func @shift_right_logical_vector(%arg0: vector<4xi64>, %arg1: vector<4xsi64>, %arg2: vector<4xi32>, %arg3: vector<4xui32>) "None" {
// CHECK: llvm.lshr %{{.*}}, %{{.*}} : vector<4xi64>
%0 = spirv.ShiftRightLogical %arg0, %arg0 : vector<4xi64>, vector<4xi64>
// CHECK: llvm.lshr %{{.*}}, %{{.*}} : vector<4xi64>
%1 = spirv.ShiftRightLogical %arg0, %arg1 : vector<4xi64>, vector<4xsi64>
// CHECK: %[[SEXT:.*]] = llvm.sext %{{.*}} : vector<4xi32> to vector<4xi64>
// CHECK: llvm.lshr %{{.*}}, %[[SEXT]] : vector<4xi64>
%2 = spirv.ShiftRightLogical %arg0, %arg2 : vector<4xi64>, vector<4xi32>
// CHECK: %[[ZEXT:.*]] = llvm.zext %{{.*}} : vector<4xi32> to vector<4xi64>
// CHECK: llvm.lshr %{{.*}}, %[[ZEXT]] : vector<4xi64>
%3 = spirv.ShiftRightLogical %arg0, %arg3 : vector<4xi64>, vector<4xui32>
spirv.Return
}
//===----------------------------------------------------------------------===//
// spirv.ShiftLeftLogical
//===----------------------------------------------------------------------===//
// CHECK-LABEL: @shift_left_logical_scalar
spirv.func @shift_left_logical_scalar(%arg0: i32, %arg1: si32, %arg2 : i16, %arg3 : ui16) "None" {
// CHECK: llvm.shl %{{.*}}, %{{.*}} : i32
%0 = spirv.ShiftLeftLogical %arg0, %arg0 : i32, i32
// CHECK: llvm.shl %{{.*}}, %{{.*}} : i32
%1 = spirv.ShiftLeftLogical %arg0, %arg1 : i32, si32
// CHECK: %[[SEXT:.*]] = llvm.sext %{{.*}} : i16 to i32
// CHECK: llvm.shl %{{.*}}, %[[SEXT]] : i32
%2 = spirv.ShiftLeftLogical %arg0, %arg2 : i32, i16
// CHECK: %[[ZEXT:.*]] = llvm.zext %{{.*}} : i16 to i32
// CHECK: llvm.shl %{{.*}}, %[[ZEXT]] : i32
%3 = spirv.ShiftLeftLogical %arg0, %arg3 : i32, ui16
spirv.Return
}
// CHECK-LABEL: @shift_left_logical_vector
spirv.func @shift_left_logical_vector(%arg0: vector<4xi64>, %arg1: vector<4xsi64>, %arg2: vector<4xi32>, %arg3: vector<4xui32>) "None" {
// CHECK: llvm.shl %{{.*}}, %{{.*}} : vector<4xi64>
%0 = spirv.ShiftLeftLogical %arg0, %arg0 : vector<4xi64>, vector<4xi64>
// CHECK: llvm.shl %{{.*}}, %{{.*}} : vector<4xi64>
%1 = spirv.ShiftLeftLogical %arg0, %arg1 : vector<4xi64>, vector<4xsi64>
// CHECK: %[[SEXT:.*]] = llvm.sext %{{.*}} : vector<4xi32> to vector<4xi64>
// CHECK: llvm.shl %{{.*}}, %[[SEXT]] : vector<4xi64>
%2 = spirv.ShiftLeftLogical %arg0, %arg2 : vector<4xi64>, vector<4xi32>
// CHECK: %[[ZEXT:.*]] = llvm.zext %{{.*}} : vector<4xi32> to vector<4xi64>
// CHECK: llvm.shl %{{.*}}, %[[ZEXT]] : vector<4xi64>
%3 = spirv.ShiftLeftLogical %arg0, %arg3 : vector<4xi64>, vector<4xui32>
spirv.Return
}
|