|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 |
| 2 | +; RUN: opt < %s -S -p vector-combine | FileCheck %s |
| 3 | + |
| 4 | +define <4 x i32> @umax_fixed(i32 %x, i32 %y) { |
| 5 | +; CHECK-LABEL: define <4 x i32> @umax_fixed( |
| 6 | +; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) { |
| 7 | +; CHECK-NEXT: [[V_SCALAR:%.*]] = call i32 @llvm.umax.i32(i32 [[X]], i32 [[Y]]) |
| 8 | +; CHECK-NEXT: [[TMP1:%.*]] = call <4 x i32> @llvm.umax.v4i32(<4 x i32> poison, <4 x i32> poison) |
| 9 | +; CHECK-NEXT: [[V:%.*]] = insertelement <4 x i32> [[TMP1]], i32 [[V_SCALAR]], i64 0 |
| 10 | +; CHECK-NEXT: ret <4 x i32> [[V]] |
| 11 | +; |
| 12 | + %x.insert = insertelement <4 x i32> poison, i32 %x, i32 0 |
| 13 | + %y.insert = insertelement <4 x i32> poison, i32 %y, i32 0 |
| 14 | + %v = call <4 x i32> @llvm.umax(<4 x i32> %x.insert, <4 x i32> %y.insert) |
| 15 | + ret <4 x i32> %v |
| 16 | +} |
| 17 | + |
| 18 | +define <vscale x 4 x i32> @umax_scalable(i32 %x, i32 %y) { |
| 19 | +; CHECK-LABEL: define <vscale x 4 x i32> @umax_scalable( |
| 20 | +; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) { |
| 21 | +; CHECK-NEXT: [[V_SCALAR:%.*]] = call i32 @llvm.umax.i32(i32 [[X]], i32 [[Y]]) |
| 22 | +; CHECK-NEXT: [[TMP1:%.*]] = call <vscale x 4 x i32> @llvm.umax.nxv4i32(<vscale x 4 x i32> poison, <vscale x 4 x i32> poison) |
| 23 | +; CHECK-NEXT: [[V:%.*]] = insertelement <vscale x 4 x i32> [[TMP1]], i32 [[V_SCALAR]], i64 0 |
| 24 | +; CHECK-NEXT: ret <vscale x 4 x i32> [[V]] |
| 25 | +; |
| 26 | + %x.insert = insertelement <vscale x 4 x i32> poison, i32 %x, i32 0 |
| 27 | + %y.insert = insertelement <vscale x 4 x i32> poison, i32 %y, i32 0 |
| 28 | + %v = call <vscale x 4 x i32> @llvm.umax(<vscale x 4 x i32> %x.insert, <vscale x 4 x i32> %y.insert) |
| 29 | + ret <vscale x 4 x i32> %v |
| 30 | +} |
| 31 | + |
| 32 | +define <4 x i32> @umax_fixed_lhs_const(i32 %x) { |
| 33 | +; CHECK-LABEL: define <4 x i32> @umax_fixed_lhs_const( |
| 34 | +; CHECK-SAME: i32 [[X:%.*]]) { |
| 35 | +; CHECK-NEXT: [[V_SCALAR:%.*]] = call i32 @llvm.umax.i32(i32 1, i32 [[X]]) |
| 36 | +; CHECK-NEXT: [[TMP1:%.*]] = call <4 x i32> @llvm.umax.v4i32(<4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32> poison) |
| 37 | +; CHECK-NEXT: [[V:%.*]] = insertelement <4 x i32> [[TMP1]], i32 [[V_SCALAR]], i64 0 |
| 38 | +; CHECK-NEXT: ret <4 x i32> [[V]] |
| 39 | +; |
| 40 | + %x.insert = insertelement <4 x i32> poison, i32 %x, i32 0 |
| 41 | + %v = call <4 x i32> @llvm.umax(<4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32> %x.insert) |
| 42 | + ret <4 x i32> %v |
| 43 | +} |
| 44 | + |
| 45 | +define <4 x i32> @umax_fixed_rhs_const(i32 %x) { |
| 46 | +; CHECK-LABEL: define <4 x i32> @umax_fixed_rhs_const( |
| 47 | +; CHECK-SAME: i32 [[X:%.*]]) { |
| 48 | +; CHECK-NEXT: [[V_SCALAR:%.*]] = call i32 @llvm.umax.i32(i32 [[X]], i32 1) |
| 49 | +; CHECK-NEXT: [[TMP1:%.*]] = call <4 x i32> @llvm.umax.v4i32(<4 x i32> poison, <4 x i32> <i32 1, i32 2, i32 3, i32 4>) |
| 50 | +; CHECK-NEXT: [[V:%.*]] = insertelement <4 x i32> [[TMP1]], i32 [[V_SCALAR]], i64 0 |
| 51 | +; CHECK-NEXT: ret <4 x i32> [[V]] |
| 52 | +; |
| 53 | + %x.insert = insertelement <4 x i32> poison, i32 %x, i32 0 |
| 54 | + %v = call <4 x i32> @llvm.umax(<4 x i32> %x.insert, <4 x i32> <i32 1, i32 2, i32 3, i32 4>) |
| 55 | + ret <4 x i32> %v |
| 56 | +} |
| 57 | + |
| 58 | +define <vscale x 4 x i32> @umax_scalable_lhs_const(i32 %x) { |
| 59 | +; CHECK-LABEL: define <vscale x 4 x i32> @umax_scalable_lhs_const( |
| 60 | +; CHECK-SAME: i32 [[X:%.*]]) { |
| 61 | +; CHECK-NEXT: [[V_SCALAR:%.*]] = call i32 @llvm.umax.i32(i32 42, i32 [[X]]) |
| 62 | +; CHECK-NEXT: [[TMP1:%.*]] = call <vscale x 4 x i32> @llvm.umax.nxv4i32(<vscale x 4 x i32> splat (i32 42), <vscale x 4 x i32> poison) |
| 63 | +; CHECK-NEXT: [[V:%.*]] = insertelement <vscale x 4 x i32> [[TMP1]], i32 [[V_SCALAR]], i64 0 |
| 64 | +; CHECK-NEXT: ret <vscale x 4 x i32> [[V]] |
| 65 | +; |
| 66 | + %x.insert = insertelement <vscale x 4 x i32> poison, i32 %x, i32 0 |
| 67 | + %v = call <vscale x 4 x i32> @llvm.umax(<vscale x 4 x i32> splat (i32 42), <vscale x 4 x i32> %x.insert) |
| 68 | + ret <vscale x 4 x i32> %v |
| 69 | +} |
| 70 | + |
| 71 | +define <vscale x 4 x i32> @umax_scalable_rhs_const(i32 %x) { |
| 72 | +; CHECK-LABEL: define <vscale x 4 x i32> @umax_scalable_rhs_const( |
| 73 | +; CHECK-SAME: i32 [[X:%.*]]) { |
| 74 | +; CHECK-NEXT: [[V_SCALAR:%.*]] = call i32 @llvm.umax.i32(i32 [[X]], i32 42) |
| 75 | +; CHECK-NEXT: [[TMP1:%.*]] = call <vscale x 4 x i32> @llvm.umax.nxv4i32(<vscale x 4 x i32> poison, <vscale x 4 x i32> splat (i32 42)) |
| 76 | +; CHECK-NEXT: [[V:%.*]] = insertelement <vscale x 4 x i32> [[TMP1]], i32 [[V_SCALAR]], i64 0 |
| 77 | +; CHECK-NEXT: ret <vscale x 4 x i32> [[V]] |
| 78 | +; |
| 79 | + %x.insert = insertelement <vscale x 4 x i32> poison, i32 %x, i32 0 |
| 80 | + %v = call <vscale x 4 x i32> @llvm.umax(<vscale x 4 x i32> %x.insert, <vscale x 4 x i32> splat (i32 42)) |
| 81 | + ret <vscale x 4 x i32> %v |
| 82 | +} |
| 83 | + |
| 84 | +; Shouldn't be scalarized, not a "trivially vectorizable" intrinsic. |
| 85 | +define <4 x i32> @non_trivially_vectorizable(i32 %x, i32 %y) { |
| 86 | +; CHECK-LABEL: define <4 x i32> @non_trivially_vectorizable( |
| 87 | +; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) { |
| 88 | +; CHECK-NEXT: [[X_INSERT:%.*]] = insertelement <4 x i32> poison, i32 [[X]], i32 0 |
| 89 | +; CHECK-NEXT: [[Y_INSERT:%.*]] = insertelement <8 x i32> poison, i32 [[Y]], i32 0 |
| 90 | +; CHECK-NEXT: [[V:%.*]] = call <4 x i32> @llvm.experimental.vector.partial.reduce.add.v4i32.v8i32(<4 x i32> [[X_INSERT]], <8 x i32> [[Y_INSERT]]) |
| 91 | +; CHECK-NEXT: ret <4 x i32> [[V]] |
| 92 | +; |
| 93 | + %x.insert = insertelement <4 x i32> poison, i32 %x, i32 0 |
| 94 | + %y.insert = insertelement <8 x i32> poison, i32 %y, i32 0 |
| 95 | + %v = call <4 x i32> @llvm.experimental.vector.partial.reduce.add(<4 x i32> %x.insert, <8 x i32> %y.insert) |
| 96 | + ret <4 x i32> %v |
| 97 | +} |
| 98 | + |
| 99 | +; TODO: We should be able to scalarize this if we preserve the scalar argument. |
| 100 | +define <4 x float> @scalar_argument(float %x) { |
| 101 | +; CHECK-LABEL: define <4 x float> @scalar_argument( |
| 102 | +; CHECK-SAME: float [[X:%.*]]) { |
| 103 | +; CHECK-NEXT: [[X_INSERT:%.*]] = insertelement <4 x float> poison, float [[X]], i32 0 |
| 104 | +; CHECK-NEXT: [[V:%.*]] = call <4 x float> @llvm.powi.v4f32.i32(<4 x float> [[X_INSERT]], i32 42) |
| 105 | +; CHECK-NEXT: ret <4 x float> [[V]] |
| 106 | +; |
| 107 | + %x.insert = insertelement <4 x float> poison, float %x, i32 0 |
| 108 | + %v = call <4 x float> @llvm.powi(<4 x float> %x.insert, i32 42) |
| 109 | + ret <4 x float> %v |
| 110 | +} |
| 111 | + |
| 112 | +define <4 x i2> @scmp(i32 %x) { |
| 113 | +; CHECK-LABEL: define <4 x i2> @scmp( |
| 114 | +; CHECK-SAME: i32 [[X:%.*]]) { |
| 115 | +; CHECK-NEXT: [[X_INSERT:%.*]] = insertelement <4 x i32> poison, i32 [[X]], i32 0 |
| 116 | +; CHECK-NEXT: [[V:%.*]] = call <4 x i2> @llvm.scmp.v4i2.v4i32(<4 x i32> [[X_INSERT]], <4 x i32> zeroinitializer) |
| 117 | +; CHECK-NEXT: ret <4 x i2> [[V]] |
| 118 | +; |
| 119 | + %x.insert = insertelement <4 x i32> poison, i32 %x, i32 0 |
| 120 | + %v = call <4 x i2> @llvm.scmp(<4 x i32> %x.insert, <4 x i32> splat (i32 0)) |
| 121 | + ret <4 x i2> %v |
| 122 | +} |
0 commit comments