diff --git a/mlir/test/Conversion/SPIRVToLLVM/constant-op-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/constant-op-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/constant-op-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/constant-op-to-llvm.mlir @@ -4,52 +4,58 @@ // spv.constant //===----------------------------------------------------------------------===// +// CHECK-LABEL: @bool_constant_scalar func @bool_constant_scalar() { - // CHECK: {{.*}} = llvm.mlir.constant(true) : !llvm.i1 + // CHECK: llvm.mlir.constant(true) : !llvm.i1 %0 = spv.constant true - // CHECK: {{.*}} = llvm.mlir.constant(false) : !llvm.i1 + // CHECK: llvm.mlir.constant(false) : !llvm.i1 %1 = spv.constant false return } +// CHECK-LABEL: @bool_constant_vector func @bool_constant_vector() { - // CHECK: {{.*}} = llvm.mlir.constant(dense<[true, false]> : vector<2xi1>) : !llvm.vec<2 x i1> + // CHECK: llvm.mlir.constant(dense<[true, false]> : vector<2xi1>) : !llvm.vec<2 x i1> %0 = constant dense<[true, false]> : vector<2xi1> - // CHECK: {{.*}} = llvm.mlir.constant(dense : vector<3xi1>) : !llvm.vec<3 x i1> + // CHECK: llvm.mlir.constant(dense : vector<3xi1>) : !llvm.vec<3 x i1> %1 = constant dense : vector<3xi1> return } +// CHECK-LABEL: @integer_constant_scalar func @integer_constant_scalar() { - // CHECK: {{.*}} = llvm.mlir.constant(0 : i8) : !llvm.i8 + // CHECK: llvm.mlir.constant(0 : i8) : !llvm.i8 %0 = spv.constant 0 : i8 - // CHECK: {{.*}} = llvm.mlir.constant(-5 : i64) : !llvm.i64 + // CHECK: llvm.mlir.constant(-5 : i64) : !llvm.i64 %1 = spv.constant -5 : si64 - // CHECK: {{.*}} = llvm.mlir.constant(10 : i16) : !llvm.i16 + // CHECK: llvm.mlir.constant(10 : i16) : !llvm.i16 %2 = spv.constant 10 : ui16 return } +// CHECK-LABEL: @integer_constant_vector func @integer_constant_vector() { - // CHECK: {{.*}} = llvm.mlir.constant(dense<[2, 3]> : vector<2xi32>) : !llvm.vec<2 x i32> + // CHECK: llvm.mlir.constant(dense<[2, 3]> : vector<2xi32>) : !llvm.vec<2 x i32> %0 = spv.constant dense<[2, 3]> : vector<2xi32> - // CHECK: {{.*}} = llvm.mlir.constant(dense<-4> : vector<2xi32>) : !llvm.vec<2 x i32> + // CHECK: llvm.mlir.constant(dense<-4> : vector<2xi32>) : !llvm.vec<2 x i32> %1 = spv.constant dense<-4> : vector<2xsi32> - // CHECK: {{.*}} = llvm.mlir.constant(dense<[2, 3, 4]> : vector<3xi32>) : !llvm.vec<3 x i32> + // CHECK: llvm.mlir.constant(dense<[2, 3, 4]> : vector<3xi32>) : !llvm.vec<3 x i32> %2 = spv.constant dense<[2, 3, 4]> : vector<3xui32> return } +// CHECK-LABEL: @float_constant_scalar func @float_constant_scalar() { - // CHECK: {{.*}} = llvm.mlir.constant(5.000000e+00 : f16) : !llvm.half + // CHECK: llvm.mlir.constant(5.000000e+00 : f16) : !llvm.half %0 = spv.constant 5.000000e+00 : f16 - // CHECK: {{.*}} = llvm.mlir.constant(5.000000e+00 : f64) : !llvm.double + // CHECK: llvm.mlir.constant(5.000000e+00 : f64) : !llvm.double %1 = spv.constant 5.000000e+00 : f64 return } +// CHECK-LABEL: @float_constant_vector func @float_constant_vector() { - // CHECK: {{.*}} = llvm.mlir.constant(dense<[2.000000e+00, 3.000000e+00]> : vector<2xf32>) : !llvm.vec<2 x float> + // CHECK: llvm.mlir.constant(dense<[2.000000e+00, 3.000000e+00]> : vector<2xf32>) : !llvm.vec<2 x float> %0 = spv.constant dense<[2.000000e+00, 3.000000e+00]> : vector<2xf32> return } diff --git a/mlir/test/Conversion/SPIRVToLLVM/func-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/func-ops-to-llvm.mlir rename from mlir/test/Conversion/SPIRVToLLVM/func-to-llvm.mlir rename to mlir/test/Conversion/SPIRVToLLVM/func-ops-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/func-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/func-ops-to-llvm.mlir @@ -4,18 +4,20 @@ // spv.Return //===----------------------------------------------------------------------===// +// CHECK-LABEL: @return func @return() { - // CHECK: llvm.return - spv.Return + // CHECK: llvm.return + spv.Return } //===----------------------------------------------------------------------===// // spv.ReturnValue //===----------------------------------------------------------------------===// +// CHECK-LABEL: @return_value func @return_value(%arg: i32) { - // CHECK: llvm.return %{{.*}} : !llvm.i32 - spv.ReturnValue %arg : i32 + // CHECK: llvm.return %{{.*}} : !llvm.i32 + spv.ReturnValue %arg : i32 } //===----------------------------------------------------------------------===// @@ -24,38 +26,38 @@ // CHECK-LABEL: llvm.func @none() spv.func @none() -> () "None" { - spv.Return + spv.Return } // CHECK-LABEL: llvm.func @inline() attributes {passthrough = ["alwaysinline"]} spv.func @inline() -> () "Inline" { - spv.Return + spv.Return } // CHECK-LABEL: llvm.func @dont_inline() attributes {passthrough = ["noinline"]} spv.func @dont_inline() -> () "DontInline" { - spv.Return + spv.Return } // CHECK-LABEL: llvm.func @pure() attributes {passthrough = ["readonly"]} spv.func @pure() -> () "Pure" { - spv.Return + spv.Return } // CHECK-LABEL: llvm.func @const() attributes {passthrough = ["readnone"]} spv.func @const() -> () "Const" { - spv.Return + spv.Return } // CHECK-LABEL: llvm.func @scalar_types(%arg0: !llvm.i32, %arg1: !llvm.i1, %arg2: !llvm.double, %arg3: !llvm.float) spv.func @scalar_types(%arg0: i32, %arg1: i1, %arg2: f64, %arg3: f32) -> () "None" { - spv.Return + spv.Return } // CHECK-LABEL: llvm.func @vector_types(%arg0: !llvm.vec<2 x i64>, %arg1: !llvm.vec<2 x i64>) -> !llvm.vec<2 x i64> spv.func @vector_types(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> "None" { - %0 = spv.IAdd %arg0, %arg1 : vector<2xi64> - spv.ReturnValue %0 : vector<2xi64> + %0 = spv.IAdd %arg0, %arg1 : vector<2xi64> + spv.ReturnValue %0 : vector<2xi64> } //===----------------------------------------------------------------------===// @@ -65,15 +67,15 @@ // CHECK-LABEL: llvm.func @function_calls // CHECK-SAME: %[[ARG0:.*]]: !llvm.i32, %[[ARG1:.*]]: !llvm.i1, %[[ARG2:.*]]: !llvm.double, %[[ARG3:.*]]: !llvm.vec<2 x i64>, %[[ARG4:.*]]: !llvm.vec<2 x float> spv.func @function_calls(%arg0: i32, %arg1: i1, %arg2: f64, %arg3: vector<2xi64>, %arg4: vector<2xf32>) -> () "None" { - // CHECK: llvm.call @void_1() : () -> () - spv.FunctionCall @void_1() : () -> () - // CHECK: llvm.call @void_2(%[[ARG3]]) : (!llvm.vec<2 x i64>) -> () - spv.FunctionCall @void_2(%arg3) : (vector<2xi64>) -> () - // CHECK: %{{.*}} = llvm.call @value_scalar(%[[ARG0]], %[[ARG1]], %[[ARG2]]) : (!llvm.i32, !llvm.i1, !llvm.double) -> !llvm.i32 - %0 = spv.FunctionCall @value_scalar(%arg0, %arg1, %arg2) : (i32, i1, f64) -> i32 - // CHECK: %{{.*}} = llvm.call @value_vector(%[[ARG3]], %[[ARG4]]) : (!llvm.vec<2 x i64>, !llvm.vec<2 x float>) -> !llvm.vec<2 x float> - %1 = spv.FunctionCall @value_vector(%arg3, %arg4) : (vector<2xi64>, vector<2xf32>) -> vector<2xf32> - spv.Return + // CHECK: llvm.call @void_1() : () -> () + // CHECK: llvm.call @void_2(%[[ARG3]]) : (!llvm.vec<2 x i64>) -> () + // CHECK: llvm.call @value_scalar(%[[ARG0]], %[[ARG1]], %[[ARG2]]) : (!llvm.i32, !llvm.i1, !llvm.double) -> !llvm.i32 + // CHECK: llvm.call @value_vector(%[[ARG3]], %[[ARG4]]) : (!llvm.vec<2 x i64>, !llvm.vec<2 x float>) -> !llvm.vec<2 x float> + spv.FunctionCall @void_1() : () -> () + spv.FunctionCall @void_2(%arg3) : (vector<2xi64>) -> () + %0 = spv.FunctionCall @value_scalar(%arg0, %arg1, %arg2) : (i32, i1, f64) -> i32 + %1 = spv.FunctionCall @value_vector(%arg3, %arg4) : (vector<2xi64>, vector<2xf32>) -> vector<2xf32> + spv.Return } spv.func @void_1() -> () "None" { diff --git a/mlir/test/Conversion/SPIRVToLLVM/memory-ops-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/memory-ops-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/memory-ops-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/memory-ops-to-llvm.mlir @@ -4,37 +4,42 @@ // spv.Load //===----------------------------------------------------------------------===// +// CHECK-LABEL: @load func @load() { %0 = spv.Variable : !spv.ptr - // CHECK: %{{.*}} = llvm.load %{{.*}} : !llvm.ptr + // CHECK: llvm.load %{{.*}} : !llvm.ptr %1 = spv.Load "Function" %0 : f32 return } +// CHECK-LABEL: @load_none func @load_none() { %0 = spv.Variable : !spv.ptr - // CHECK: %{{.*}} = llvm.load %{{.*}} : !llvm.ptr + // CHECK: llvm.load %{{.*}} : !llvm.ptr %1 = spv.Load "Function" %0 ["None"] : f32 return } +// CHECK-LABEL: @load_with_alignment func @load_with_alignment() { %0 = spv.Variable : !spv.ptr - // CHECK: %{{.*}} = llvm.load %{{.*}} {alignment = 4 : i64} : !llvm.ptr + // CHECK: llvm.load %{{.*}} {alignment = 4 : i64} : !llvm.ptr %1 = spv.Load "Function" %0 ["Aligned", 4] : f32 return } +// CHECK-LABEL: @load_volatile func @load_volatile() { %0 = spv.Variable : !spv.ptr - // CHECK: %{{.*}} = llvm.load volatile %{{.*}} : !llvm.ptr + // CHECK: llvm.load volatile %{{.*}} : !llvm.ptr %1 = spv.Load "Function" %0 ["Volatile"] : f32 return } +// CHECK-LABEL: @load_nontemporal func @load_nontemporal() { %0 = spv.Variable : !spv.ptr - // CHECK: %{{.*}} = llvm.load %{{.*}} {nontemporal} : !llvm.ptr + // CHECK: llvm.load %{{.*}} {nontemporal} : !llvm.ptr %1 = spv.Load "Function" %0 ["Nontemporal"] : f32 return } @@ -43,6 +48,7 @@ // spv.Store //===----------------------------------------------------------------------===// +// CHECK-LABEL: @store func @store(%arg0 : f32) -> () { %0 = spv.Variable : !spv.ptr // CHECK: llvm.store %{{.*}}, %{{.*}} : !llvm.ptr @@ -50,6 +56,7 @@ return } +// CHECK-LABEL: @store_composite func @store_composite(%arg0 : !spv.struct) -> () { %0 = spv.Variable : !spv.ptr, Function> // CHECK: llvm.store %{{.*}}, %{{.*}} : !llvm.ptr> @@ -57,6 +64,7 @@ return } +// CHECK-LABEL: @store_with_alignment func @store_with_alignment(%arg0 : f32) -> () { %0 = spv.Variable : !spv.ptr // CHECK: llvm.store %{{.*}}, %{{.*}} {alignment = 4 : i64} : !llvm.ptr @@ -64,6 +72,7 @@ return } +// CHECK-LABEL: @store_volatile func @store_volatile(%arg0 : f32) -> () { %0 = spv.Variable : !spv.ptr // CHECK: llvm.store volatile %{{.*}}, %{{.*}} : !llvm.ptr @@ -71,6 +80,7 @@ return } +// CHECK-LABEL: @store_nontemporal func @store_nontemporal(%arg0 : f32) -> () { %0 = spv.Variable : !spv.ptr // CHECK: llvm.store %{{.*}}, %{{.*}} {nontemporal} : !llvm.ptr @@ -82,16 +92,18 @@ // spv.Variable //===----------------------------------------------------------------------===// +// CHECK-LABEL: @variable_scalar func @variable_scalar() { // CHECK: %[[SIZE1:.*]] = llvm.mlir.constant(1 : i32) : !llvm.i32 - // CHECK: %{{.*}} = llvm.alloca %[[SIZE1]] x !llvm.float : (!llvm.i32) -> !llvm.ptr + // CHECK: llvm.alloca %[[SIZE1]] x !llvm.float : (!llvm.i32) -> !llvm.ptr %0 = spv.Variable : !spv.ptr // CHECK: %[[SIZE2:.*]] = llvm.mlir.constant(1 : i32) : !llvm.i32 - // CHECK: %{{.*}} = llvm.alloca %[[SIZE2]] x !llvm.i8 : (!llvm.i32) -> !llvm.ptr + // CHECK: llvm.alloca %[[SIZE2]] x !llvm.i8 : (!llvm.i32) -> !llvm.ptr %1 = spv.Variable : !spv.ptr return } +// CHECK-LABEL: @variable_scalar_with_initialization func @variable_scalar_with_initialization() { // CHECK: %[[VALUE:.*]] = llvm.mlir.constant(0 : i64) : !llvm.i64 // CHECK: %[[SIZE:.*]] = llvm.mlir.constant(1 : i32) : !llvm.i32 @@ -102,13 +114,15 @@ return } +// CHECK-LABEL: @variable_vector func @variable_vector() { // CHECK: %[[SIZE:.*]] = llvm.mlir.constant(1 : i32) : !llvm.i32 - // CHECK: %{{.*}} = llvm.alloca %[[SIZE]] x !llvm.vec<3 x float> : (!llvm.i32) -> !llvm.ptr> + // CHECK: llvm.alloca %[[SIZE]] x !llvm.vec<3 x float> : (!llvm.i32) -> !llvm.ptr> %0 = spv.Variable : !spv.ptr, Function> return } +// CHECK-LABEL: @variable_vector_with_initialization func @variable_vector_with_initialization() { // CHECK: %[[VALUE:.*]] = llvm.mlir.constant(dense : vector<3xi1>) : !llvm.vec<3 x i1> // CHECK: %[[SIZE:.*]] = llvm.mlir.constant(1 : i32) : !llvm.i32 @@ -119,9 +133,10 @@ return } +// CHECK-LABEL: @variable_array func @variable_array() { // CHECK: %[[SIZE:.*]] = llvm.mlir.constant(1 : i32) : !llvm.i32 - // CHECK: %{{.*}} = llvm.alloca %[[SIZE]] x !llvm.array<10 x i32> : (!llvm.i32) -> !llvm.ptr> + // CHECK: llvm.alloca %[[SIZE]] x !llvm.array<10 x i32> : (!llvm.i32) -> !llvm.ptr> %0 = spv.Variable : !spv.ptr, Function> return } diff --git a/mlir/test/Conversion/SPIRVToLLVM/misc-ops-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/misc-ops-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/misc-ops-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/misc-ops-to-llvm.mlir @@ -4,17 +4,19 @@ // spv.Select //===----------------------------------------------------------------------===// +// CHECK-LABEL: @select_scalar func @select_scalar(%arg0: i1, %arg1: vector<3xi32>, %arg2: f32) { - // CHECK: %{{.*}} = llvm.select %{{.*}}, %{{.*}}, %{{.*}} : !llvm.i1, !llvm.vec<3 x i32> - %0 = spv.Select %arg0, %arg1, %arg1 : i1, vector<3xi32> - // CHECK: %{{.*}} = llvm.select %{{.*}}, %{{.*}}, %{{.*}} : !llvm.i1, !llvm.float - %1 = spv.Select %arg0, %arg2, %arg2 : i1, f32 + // CHECK: llvm.select %{{.*}}, %{{.*}}, %{{.*}} : !llvm.i1, !llvm.vec<3 x i32> + %0 = spv.Select %arg0, %arg1, %arg1 : i1, vector<3xi32> + // CHECK: llvm.select %{{.*}}, %{{.*}}, %{{.*}} : !llvm.i1, !llvm.float + %1 = spv.Select %arg0, %arg2, %arg2 : i1, f32 return } +// CHECK-LABEL: @select_vector func @select_vector(%arg0: vector<2xi1>, %arg1: vector<2xi32>) { - // CHECK: %{{.*}} = llvm.select %{{.*}}, %{{.*}}, %{{.*}} : !llvm.vec<2 x i1>, !llvm.vec<2 x i32> - %0 = spv.Select %arg0, %arg1, %arg1 : vector<2xi1>, vector<2xi32> + // CHECK: llvm.select %{{.*}}, %{{.*}}, %{{.*}} : !llvm.vec<2 x i1>, !llvm.vec<2 x i32> + %0 = spv.Select %arg0, %arg1, %arg1 : vector<2xi1>, vector<2xi32> return } @@ -22,14 +24,16 @@ // spv.Undef //===----------------------------------------------------------------------===// +// CHECK-LABEL: @undef_scalar func @undef_scalar() { - // CHECK: %{{.*}} = llvm.mlir.undef : !llvm.float - %0 = spv.undef : f32 - return + // CHECK: llvm.mlir.undef : !llvm.float + %0 = spv.undef : f32 + return } +// CHECK-LABEL: @undef_vector func @undef_vector() { - // CHECK: %{{.*}} = llvm.mlir.undef : !llvm.vec<2 x i32> - %0 = spv.undef : vector<2xi32> - return + // CHECK: llvm.mlir.undef : !llvm.vec<2 x i32> + %0 = spv.undef : vector<2xi32> + return } diff --git a/mlir/test/Conversion/SPIRVToLLVM/shift-ops-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/shift-ops-to-llvm.mlir new file mode 100644 --- /dev/null +++ b/mlir/test/Conversion/SPIRVToLLVM/shift-ops-to-llvm.mlir @@ -0,0 +1,121 @@ +// RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s + +//===----------------------------------------------------------------------===// +// spv.ShiftRightArithmetic +//===----------------------------------------------------------------------===// + +// CHECK-LABEL: @shift_right_arithmetic_scalar +func @shift_right_arithmetic_scalar(%arg0: i32, %arg1: si32, %arg2 : i16, %arg3 : ui16) { + // CHECK: llvm.ashr %{{.*}}, %{{.*}} : !llvm.i32 + %0 = spv.ShiftRightArithmetic %arg0, %arg0 : i32, i32 + + // CHECK: llvm.ashr %{{.*}}, %{{.*}} : !llvm.i32 + %1 = spv.ShiftRightArithmetic %arg0, %arg1 : i32, si32 + + // CHECK: %[[SEXT:.*]] = llvm.sext %{{.*}} : !llvm.i16 to !llvm.i32 + // CHECK: llvm.ashr %{{.*}}, %[[SEXT]] : !llvm.i32 + %2 = spv.ShiftRightArithmetic %arg0, %arg2 : i32, i16 + + // CHECK: %[[ZEXT:.*]] = llvm.zext %{{.*}} : !llvm.i16 to !llvm.i32 + // CHECK: llvm.ashr %{{.*}}, %[[ZEXT]] : !llvm.i32 + %3 = spv.ShiftRightArithmetic %arg0, %arg3 : i32, ui16 + return +} + +// CHECK-LABEL: @shift_right_arithmetic_vector +func @shift_right_arithmetic_vector(%arg0: vector<4xi64>, %arg1: vector<4xui64>, %arg2: vector<4xi32>, %arg3: vector<4xui32>) { + // CHECK: llvm.ashr %{{.*}}, %{{.*}} : !llvm.vec<4 x i64> + %0 = spv.ShiftRightArithmetic %arg0, %arg0 : vector<4xi64>, vector<4xi64> + + // CHECK: llvm.ashr %{{.*}}, %{{.*}} : !llvm.vec<4 x i64> + %1 = spv.ShiftRightArithmetic %arg0, %arg1 : vector<4xi64>, vector<4xui64> + + // CHECK: %[[SEXT:.*]] = llvm.sext %{{.*}} : !llvm.vec<4 x i32> to !llvm.vec<4 x i64> + // CHECK: llvm.ashr %{{.*}}, %[[SEXT]] : !llvm.vec<4 x i64> + %2 = spv.ShiftRightArithmetic %arg0, %arg2 : vector<4xi64>, vector<4xi32> + + // CHECK: %[[ZEXT:.*]] = llvm.zext %{{.*}} : !llvm.vec<4 x i32> to !llvm.vec<4 x i64> + // CHECK: llvm.ashr %{{.*}}, %[[ZEXT]] : !llvm.vec<4 x i64> + %3 = spv.ShiftRightArithmetic %arg0, %arg3 : vector<4xi64>, vector<4xui32> + return +} + +//===----------------------------------------------------------------------===// +// spv.ShiftRightLogical +//===----------------------------------------------------------------------===// + +// CHECK-LABEL: @shift_right_logical_scalar +func @shift_right_logical_scalar(%arg0: i32, %arg1: si32, %arg2 : si16, %arg3 : ui16) { + // CHECK: llvm.lshr %{{.*}}, %{{.*}} : !llvm.i32 + %0 = spv.ShiftRightLogical %arg0, %arg0 : i32, i32 + + // CHECK: llvm.lshr %{{.*}}, %{{.*}} : !llvm.i32 + %1 = spv.ShiftRightLogical %arg0, %arg1 : i32, si32 + + // CHECK: %[[SEXT:.*]] = llvm.sext %{{.*}} : !llvm.i16 to !llvm.i32 + // CHECK: llvm.lshr %{{.*}}, %[[SEXT]] : !llvm.i32 + %2 = spv.ShiftRightLogical %arg0, %arg2 : i32, si16 + + // CHECK: %[[ZEXT:.*]] = llvm.zext %{{.*}} : !llvm.i16 to !llvm.i32 + // CHECK: llvm.lshr %{{.*}}, %[[ZEXT]] : !llvm.i32 + %3 = spv.ShiftRightLogical %arg0, %arg3 : i32, ui16 + return +} + +// CHECK-LABEL: @shift_right_logical_vector +func @shift_right_logical_vector(%arg0: vector<4xi64>, %arg1: vector<4xsi64>, %arg2: vector<4xi32>, %arg3: vector<4xui32>) { + // CHECK: llvm.lshr %{{.*}}, %{{.*}} : !llvm.vec<4 x i64> + %0 = spv.ShiftRightLogical %arg0, %arg0 : vector<4xi64>, vector<4xi64> + + // CHECK: llvm.lshr %{{.*}}, %{{.*}} : !llvm.vec<4 x i64> + %1 = spv.ShiftRightLogical %arg0, %arg1 : vector<4xi64>, vector<4xsi64> + + // CHECK: %[[SEXT:.*]] = llvm.sext %{{.*}} : !llvm.vec<4 x i32> to !llvm.vec<4 x i64> + // CHECK: llvm.lshr %{{.*}}, %[[SEXT]] : !llvm.vec<4 x i64> + %2 = spv.ShiftRightLogical %arg0, %arg2 : vector<4xi64>, vector<4xi32> + + // CHECK: %[[ZEXT:.*]] = llvm.zext %{{.*}} : !llvm.vec<4 x i32> to !llvm.vec<4 x i64> + // CHECK: llvm.lshr %{{.*}}, %[[ZEXT]] : !llvm.vec<4 x i64> + %3 = spv.ShiftRightLogical %arg0, %arg3 : vector<4xi64>, vector<4xui32> + return +} + +//===----------------------------------------------------------------------===// +// spv.ShiftLeftLogical +//===----------------------------------------------------------------------===// + +// CHECK-LABEL: @shift_left_logical_scalar +func @shift_left_logical_scalar(%arg0: i32, %arg1: si32, %arg2 : i16, %arg3 : ui16) { + // CHECK: llvm.shl %{{.*}}, %{{.*}} : !llvm.i32 + %0 = spv.ShiftLeftLogical %arg0, %arg0 : i32, i32 + + // CHECK: llvm.shl %{{.*}}, %{{.*}} : !llvm.i32 + %1 = spv.ShiftLeftLogical %arg0, %arg1 : i32, si32 + + // CHECK: %[[SEXT:.*]] = llvm.sext %{{.*}} : !llvm.i16 to !llvm.i32 + // CHECK: llvm.shl %{{.*}}, %[[SEXT]] : !llvm.i32 + %2 = spv.ShiftLeftLogical %arg0, %arg2 : i32, i16 + + // CHECK: %[[ZEXT:.*]] = llvm.zext %{{.*}} : !llvm.i16 to !llvm.i32 + // CHECK: llvm.shl %{{.*}}, %[[ZEXT]] : !llvm.i32 + %3 = spv.ShiftLeftLogical %arg0, %arg3 : i32, ui16 + return +} + +// CHECK-LABEL: @shift_left_logical_vector +func @shift_left_logical_vector(%arg0: vector<4xi64>, %arg1: vector<4xsi64>, %arg2: vector<4xi32>, %arg3: vector<4xui32>) { + // CHECK: llvm.shl %{{.*}}, %{{.*}} : !llvm.vec<4 x i64> + %0 = spv.ShiftLeftLogical %arg0, %arg0 : vector<4xi64>, vector<4xi64> + + // CHECK: llvm.shl %{{.*}}, %{{.*}} : !llvm.vec<4 x i64> + %1 = spv.ShiftLeftLogical %arg0, %arg1 : vector<4xi64>, vector<4xsi64> + + // CHECK: %[[SEXT:.*]] = llvm.sext %{{.*}} : !llvm.vec<4 x i32> to !llvm.vec<4 x i64> + // CHECK: llvm.shl %{{.*}}, %[[SEXT]] : !llvm.vec<4 x i64> + %2 = spv.ShiftLeftLogical %arg0, %arg2 : vector<4xi64>, vector<4xi32> + + // CHECK: %[[ZEXT:.*]] = llvm.zext %{{.*}} : !llvm.vec<4 x i32> to !llvm.vec<4 x i64> + // CHECK: llvm.shl %{{.*}}, %[[ZEXT]] : !llvm.vec<4 x i64> + %3 = spv.ShiftLeftLogical %arg0, %arg3 : vector<4xi64>, vector<4xui32> + return +} diff --git a/mlir/test/Conversion/SPIRVToLLVM/shifts-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/shifts-to-llvm.mlir deleted file mode 100644 --- a/mlir/test/Conversion/SPIRVToLLVM/shifts-to-llvm.mlir +++ /dev/null @@ -1,115 +0,0 @@ -// RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s - -//===----------------------------------------------------------------------===// -// spv.ShiftRightArithmetic -//===----------------------------------------------------------------------===// - -func @shift_right_arithmetic_scalar(%arg0: i32, %arg1: si32, %arg2 : i16, %arg3 : ui16) { - // CHECK: %{{.*}} = llvm.ashr %{{.*}}, %{{.*}} : !llvm.i32 - %0 = spv.ShiftRightArithmetic %arg0, %arg0 : i32, i32 - - // CHECK: %{{.*}} = llvm.ashr %{{.*}}, %{{.*}} : !llvm.i32 - %1 = spv.ShiftRightArithmetic %arg0, %arg1 : i32, si32 - - // CHECK: %[[EXT1:.*]] = llvm.sext %{{.*}} : !llvm.i16 to !llvm.i32 - // CHECK: %{{.*}} = llvm.ashr %{{.*}}, %[[EXT1:.*]]: !llvm.i32 - %2 = spv.ShiftRightArithmetic %arg0, %arg2 : i32, i16 - - // CHECK: %[[EXT2:.*]] = llvm.zext %{{.*}} : !llvm.i16 to !llvm.i32 - // CHECK: %{{.*}} = llvm.ashr %{{.*}}, %[[EXT2:.*]]: !llvm.i32 - %3 = spv.ShiftRightArithmetic %arg0, %arg3 : i32, ui16 - return -} - -func @shift_right_arithmetic_vector(%arg0: vector<4xi64>, %arg1: vector<4xui64>, %arg2: vector<4xi32>, %arg3: vector<4xui32>) { - // CHECK: %{{.*}} = llvm.ashr %{{.*}}, %{{.*}} : !llvm.vec<4 x i64> - %0 = spv.ShiftRightArithmetic %arg0, %arg0 : vector<4xi64>, vector<4xi64> - - // CHECK: %{{.*}} = llvm.ashr %{{.*}}, %{{.*}} : !llvm.vec<4 x i64> - %1 = spv.ShiftRightArithmetic %arg0, %arg1 : vector<4xi64>, vector<4xui64> - - // CHECK: %[[EXT1:.*]] = llvm.sext %{{.*}} : !llvm.vec<4 x i32> to !llvm.vec<4 x i64> - // CHECK: %{{.*}} = llvm.ashr %{{.*}}, %[[EXT1:.*]]: !llvm.vec<4 x i64> - %2 = spv.ShiftRightArithmetic %arg0, %arg2 : vector<4xi64>, vector<4xi32> - - // CHECK: %[[EXT2:.*]] = llvm.zext %{{.*}} : !llvm.vec<4 x i32> to !llvm.vec<4 x i64> - // CHECK: %{{.*}} = llvm.ashr %{{.*}}, %[[EXT2:.*]]: !llvm.vec<4 x i64> - %3 = spv.ShiftRightArithmetic %arg0, %arg3 : vector<4xi64>, vector<4xui32> - return -} - -//===----------------------------------------------------------------------===// -// spv.ShiftRightLogical -//===----------------------------------------------------------------------===// - -func @shift_right_logical_scalar(%arg0: i32, %arg1: si32, %arg2 : si16, %arg3 : ui16) { - // CHECK: %{{.*}} = llvm.lshr %{{.*}}, %{{.*}} : !llvm.i32 - %0 = spv.ShiftRightLogical %arg0, %arg0 : i32, i32 - - // CHECK: %{{.*}} = llvm.lshr %{{.*}}, %{{.*}} : !llvm.i32 - %1 = spv.ShiftRightLogical %arg0, %arg1 : i32, si32 - - // CHECK: %[[EXT1:.*]] = llvm.sext %{{.*}} : !llvm.i16 to !llvm.i32 - // CHECK: %{{.*}} = llvm.lshr %{{.*}}, %[[EXT1:.*]]: !llvm.i32 - %2 = spv.ShiftRightLogical %arg0, %arg2 : i32, si16 - - // CHECK: %[[EXT2:.*]] = llvm.zext %{{.*}} : !llvm.i16 to !llvm.i32 - // CHECK: %{{.*}} = llvm.lshr %{{.*}}, %[[EXT2:.*]]: !llvm.i32 - %3 = spv.ShiftRightLogical %arg0, %arg3 : i32, ui16 - return -} - -func @shift_right_logical_vector(%arg0: vector<4xi64>, %arg1: vector<4xsi64>, %arg2: vector<4xi32>, %arg3: vector<4xui32>) { - // CHECK: %{{.*}} = llvm.lshr %{{.*}}, %{{.*}} : !llvm.vec<4 x i64> - %0 = spv.ShiftRightLogical %arg0, %arg0 : vector<4xi64>, vector<4xi64> - - // CHECK: %{{.*}} = llvm.lshr %{{.*}}, %{{.*}} : !llvm.vec<4 x i64> - %1 = spv.ShiftRightLogical %arg0, %arg1 : vector<4xi64>, vector<4xsi64> - - // CHECK: %[[EXT1:.*]] = llvm.sext %{{.*}} : !llvm.vec<4 x i32> to !llvm.vec<4 x i64> - // CHECK: %{{.*}} = llvm.lshr %{{.*}}, %[[EXT1:.*]]: !llvm.vec<4 x i64> - %2 = spv.ShiftRightLogical %arg0, %arg2 : vector<4xi64>, vector<4xi32> - - // CHECK: %[[EXT2:.*]] = llvm.zext %{{.*}} : !llvm.vec<4 x i32> to !llvm.vec<4 x i64> - // CHECK: %{{.*}} = llvm.lshr %{{.*}}, %[[EXT2:.*]]: !llvm.vec<4 x i64> - %3 = spv.ShiftRightLogical %arg0, %arg3 : vector<4xi64>, vector<4xui32> - return -} - -//===----------------------------------------------------------------------===// -// spv.ShiftLeftLogical -//===----------------------------------------------------------------------===// - -func @shift_left_logical_scalar(%arg0: i32, %arg1: si32, %arg2 : i16, %arg3 : ui16) { - // CHECK: %{{.*}} = llvm.shl %{{.*}}, %{{.*}} : !llvm.i32 - %0 = spv.ShiftLeftLogical %arg0, %arg0 : i32, i32 - - // CHECK: %{{.*}} = llvm.shl %{{.*}}, %{{.*}} : !llvm.i32 - %1 = spv.ShiftLeftLogical %arg0, %arg1 : i32, si32 - - // CHECK: %[[EXT1:.*]] = llvm.sext %{{.*}} : !llvm.i16 to !llvm.i32 - // CHECK: %{{.*}} = llvm.shl %{{.*}}, %[[EXT1:.*]]: !llvm.i32 - %2 = spv.ShiftLeftLogical %arg0, %arg2 : i32, i16 - - // CHECK: %[[EXT2:.*]] = llvm.zext %{{.*}} : !llvm.i16 to !llvm.i32 - // CHECK: %{{.*}} = llvm.shl %{{.*}}, %[[EXT2:.*]]: !llvm.i32 - %3 = spv.ShiftLeftLogical %arg0, %arg3 : i32, ui16 - return -} - -func @shift_left_logical_vector(%arg0: vector<4xi64>, %arg1: vector<4xsi64>, %arg2: vector<4xi32>, %arg3: vector<4xui32>) { - // CHECK: %{{.*}} = llvm.shl %{{.*}}, %{{.*}} : !llvm.vec<4 x i64> - %0 = spv.ShiftLeftLogical %arg0, %arg0 : vector<4xi64>, vector<4xi64> - - // CHECK: %{{.*}} = llvm.shl %{{.*}}, %{{.*}} : !llvm.vec<4 x i64> - %1 = spv.ShiftLeftLogical %arg0, %arg1 : vector<4xi64>, vector<4xsi64> - - // CHECK: %[[EXT1:.*]] = llvm.sext %{{.*}} : !llvm.vec<4 x i32> to !llvm.vec<4 x i64> - // CHECK: %{{.*}} = llvm.shl %{{.*}}, %[[EXT1:.*]]: !llvm.vec<4 x i64> - %2 = spv.ShiftLeftLogical %arg0, %arg2 : vector<4xi64>, vector<4xi32> - - // CHECK: %[[EXT2:.*]] = llvm.zext %{{.*}} : !llvm.vec<4 x i32> to !llvm.vec<4 x i64> - // CHECK: %{{.*}} = llvm.shl %{{.*}}, %[[EXT2:.*]]: !llvm.vec<4 x i64> - %3 = spv.ShiftLeftLogical %arg0, %arg3 : vector<4xi64>, vector<4xui32> - return -} diff --git a/mlir/test/Conversion/SPIRVToLLVM/spirv-types-to-llvm.invalid.mlir b/mlir/test/Conversion/SPIRVToLLVM/spirv-types-to-llvm-invalid.mlir rename from mlir/test/Conversion/SPIRVToLLVM/spirv-types-to-llvm.invalid.mlir rename to mlir/test/Conversion/SPIRVToLLVM/spirv-types-to-llvm-invalid.mlir