303 lines · plain
1; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s2; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %}3 4; CHECK-DAG: %[[#int_16:]] = OpTypeInt 16 05; CHECK-DAG: %[[#vec2_16:]] = OpTypeVector %[[#int_16]] 26; CHECK-DAG: %[[#vec3_16:]] = OpTypeVector %[[#int_16]] 37; CHECK-DAG: %[[#vec4_16:]] = OpTypeVector %[[#int_16]] 48; CHECK-DAG: %[[#int_32:]] = OpTypeInt 32 09; CHECK-DAG: %[[#vec2_32:]] = OpTypeVector %[[#int_32]] 210; CHECK-DAG: %[[#vec3_32:]] = OpTypeVector %[[#int_32]] 311; CHECK-DAG: %[[#vec4_32:]] = OpTypeVector %[[#int_32]] 412; CHECK-DAG: %[[#int_64:]] = OpTypeInt 64 013; CHECK-DAG: %[[#vec2_64:]] = OpTypeVector %[[#int_64]] 214; CHECK-DAG: %[[#vec3_64:]] = OpTypeVector %[[#int_64]] 315; CHECK-DAG: %[[#vec4_64:]] = OpTypeVector %[[#int_64]] 416 17define spir_func noundef i16 @test_mad_uint16_t(i16 noundef %p0, i16 noundef %p1, i16 noundef %p2) {18entry:19 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]20 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]21 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]22 ; CHECK: %[[#mul:]] = OpIMul %[[#int_16]] %[[#arg0]] %[[#arg1]]23 ; CHECK: OpIAdd %[[#int_16]] %[[#mul]] %[[#arg2]]24 %3 = mul nuw i16 %p0, %p125 %4 = add nuw i16 %3, %p226 ret i16 %427}28 29define spir_func noundef <2 x i16> @test_mad_uint16_t2(<2 x i16> noundef %p0, <2 x i16> noundef %p1, <2 x i16> noundef %p2) {30entry:31 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]32 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]33 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]34 ; CHECK: %[[#mul:]] = OpIMul %[[#vec2_16]] %[[#arg0]] %[[#arg1]]35 ; CHECK: OpIAdd %[[#vec2_16]] %[[#mul]] %[[#arg2]]36 %3 = mul nuw <2 x i16> %p0, %p137 %4 = add nuw <2 x i16> %3, %p238 ret <2 x i16> %439}40 41define spir_func noundef <3 x i16> @test_mad_uint16_t3(<3 x i16> noundef %p0, <3 x i16> noundef %p1, <3 x i16> noundef %p2) {42entry:43 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]44 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]45 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]46 ; CHECK: %[[#mul:]] = OpIMul %[[#vec3_16]] %[[#arg0]] %[[#arg1]]47 ; CHECK: OpIAdd %[[#vec3_16]] %[[#mul]] %[[#arg2]]48 %3 = mul nuw <3 x i16> %p0, %p149 %4 = add nuw <3 x i16> %3, %p250 ret <3 x i16> %451}52 53define spir_func noundef <4 x i16> @test_mad_uint16_t4(<4 x i16> noundef %p0, <4 x i16> noundef %p1, <4 x i16> noundef %p2) {54entry:55 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]56 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]57 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]58 ; CHECK: %[[#mul:]] = OpIMul %[[#vec4_16]] %[[#arg0]] %[[#arg1]]59 ; CHECK: OpIAdd %[[#vec4_16]] %[[#mul]] %[[#arg2]]60 %3 = mul nuw <4 x i16> %p0, %p161 %4 = add nuw <4 x i16> %3, %p262 ret <4 x i16> %463}64 65define spir_func noundef i16 @test_mad_int16_t(i16 noundef %p0, i16 noundef %p1, i16 noundef %p2) {66entry:67 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]68 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]69 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]70 ; CHECK: %[[#mul:]] = OpIMul %[[#int_16]] %[[#arg0]] %[[#arg1]]71 ; CHECK: OpIAdd %[[#int_16]] %[[#mul]] %[[#arg2]]72 %3 = mul nsw i16 %p0, %p173 %4 = add nsw i16 %3, %p274 ret i16 %475}76 77define spir_func noundef <2 x i16> @test_mad_int16_t2(<2 x i16> noundef %p0, <2 x i16> noundef %p1, <2 x i16> noundef %p2) {78entry:79 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]80 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]81 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]82 ; CHECK: %[[#mul:]] = OpIMul %[[#vec2_16]] %[[#arg0]] %[[#arg1]]83 ; CHECK: OpIAdd %[[#vec2_16]] %[[#mul]] %[[#arg2]]84 %3 = mul nsw <2 x i16> %p0, %p185 %4 = add nsw <2 x i16> %3, %p286 ret <2 x i16> %487}88 89define spir_func noundef <3 x i16> @test_mad_int16_t3(<3 x i16> noundef %p0, <3 x i16> noundef %p1, <3 x i16> noundef %p2) {90entry:91 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]92 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]93 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]94 ; CHECK: %[[#mul:]] = OpIMul %[[#vec3_16]] %[[#arg0]] %[[#arg1]]95 ; CHECK: OpIAdd %[[#vec3_16]] %[[#mul]] %[[#arg2]]96 %3 = mul nsw <3 x i16> %p0, %p197 %4 = add nsw <3 x i16> %3, %p298 ret <3 x i16> %499}100 101define spir_func noundef <4 x i16> @test_mad_int16_t4(<4 x i16> noundef %p0, <4 x i16> noundef %p1, <4 x i16> noundef %p2) {102entry:103 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]104 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]105 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]106 ; CHECK: %[[#mul:]] = OpIMul %[[#vec4_16]] %[[#arg0]] %[[#arg1]]107 ; CHECK: OpIAdd %[[#vec4_16]] %[[#mul]] %[[#arg2]]108 %3 = mul nsw <4 x i16> %p0, %p1109 %4 = add nsw <4 x i16> %3, %p2110 ret <4 x i16> %4111}112define spir_func noundef i32 @test_mad_int(i32 noundef %p0, i32 noundef %p1, i32 noundef %p2) {113entry:114 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]115 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]116 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]117 ; CHECK: %[[#mul:]] = OpIMul %[[#int_32]] %[[#arg0]] %[[#arg1]]118 ; CHECK: OpIAdd %[[#int_32]] %[[#mul]] %[[#arg2]]119 %3 = mul nsw i32 %p0, %p1120 %4 = add nsw i32 %3, %p2121 ret i32 %4122}123 124define spir_func noundef <2 x i32> @test_mad_int2(<2 x i32> noundef %p0, <2 x i32> noundef %p1, <2 x i32> noundef %p2) {125entry:126 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]127 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]128 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]129 ; CHECK: %[[#mul:]] = OpIMul %[[#vec2_32]] %[[#arg0]] %[[#arg1]]130 ; CHECK: OpIAdd %[[#vec2_32]] %[[#mul]] %[[#arg2]]131 %3 = mul nsw <2 x i32> %p0, %p1132 %4 = add nsw <2 x i32> %3, %p2133 ret <2 x i32> %4134}135 136define spir_func noundef <3 x i32> @test_mad_int3(<3 x i32> noundef %p0, <3 x i32> noundef %p1, <3 x i32> noundef %p2) {137entry:138 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]139 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]140 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]141 ; CHECK: %[[#mul:]] = OpIMul %[[#vec3_32]] %[[#arg0]] %[[#arg1]]142 ; CHECK: OpIAdd %[[#vec3_32]] %[[#mul]] %[[#arg2]]143 %3 = mul nsw <3 x i32> %p0, %p1144 %4 = add nsw <3 x i32> %3, %p2145 ret <3 x i32> %4146}147 148define spir_func noundef <4 x i32> @test_mad_int4(<4 x i32> noundef %p0, <4 x i32> noundef %p1, <4 x i32> noundef %p2) {149entry:150 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]151 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]152 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]153 ; CHECK: %[[#mul:]] = OpIMul %[[#vec4_32]] %[[#arg0]] %[[#arg1]]154 ; CHECK: OpIAdd %[[#vec4_32]] %[[#mul]] %[[#arg2]]155 %3 = mul nsw <4 x i32> %p0, %p1156 %4 = add nsw <4 x i32> %3, %p2157 ret <4 x i32> %4158}159 160define spir_func noundef i64 @test_mad_int64_t(i64 noundef %p0, i64 noundef %p1, i64 noundef %p2) {161entry:162 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]163 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]164 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]165 ; CHECK: %[[#mul:]] = OpIMul %[[#int_64]] %[[#arg0]] %[[#arg1]]166 ; CHECK: OpIAdd %[[#int_64]] %[[#mul]] %[[#arg2]]167 %3 = mul nsw i64 %p0, %p1168 %4 = add nsw i64 %3, %p2169 ret i64 %4170}171 172define spir_func noundef <2 x i64> @test_mad_int64_t2(<2 x i64> noundef %p0, <2 x i64> noundef %p1, <2 x i64> noundef %p2) {173entry:174 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]175 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]176 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]177 ; CHECK: %[[#mul:]] = OpIMul %[[#vec2_64]] %[[#arg0]] %[[#arg1]]178 ; CHECK: OpIAdd %[[#vec2_64]] %[[#mul]] %[[#arg2]]179 %3 = mul nsw <2 x i64> %p0, %p1180 %4 = add nsw <2 x i64> %3, %p2181 ret <2 x i64> %4182}183 184define spir_func noundef <3 x i64> @test_mad_int64_t3(<3 x i64> noundef %p0, <3 x i64> noundef %p1, <3 x i64> noundef %p2) {185entry:186 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]187 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]188 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]189 ; CHECK: %[[#mul:]] = OpIMul %[[#vec3_64]] %[[#arg0]] %[[#arg1]]190 ; CHECK: OpIAdd %[[#vec3_64]] %[[#mul]] %[[#arg2]]191 %3 = mul nsw <3 x i64> %p0, %p1192 %4 = add nsw <3 x i64> %3, %p2193 ret <3 x i64> %4194}195 196define spir_func noundef <4 x i64> @test_mad_int64_t4(<4 x i64> noundef %p0, <4 x i64> noundef %p1, <4 x i64> noundef %p2) {197entry:198 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]199 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]200 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]201 ; CHECK: %[[#mul:]] = OpIMul %[[#vec4_64]] %[[#arg0]] %[[#arg1]]202 ; CHECK: OpIAdd %[[#vec4_64]] %[[#mul]] %[[#arg2]]203 %3 = mul nsw <4 x i64> %p0, %p1204 %4 = add nsw <4 x i64> %3, %p2205 ret <4 x i64> %4206}207 208define spir_func noundef i32 @test_mad_uint(i32 noundef %p0, i32 noundef %p1, i32 noundef %p2) {209entry:210 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]211 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]212 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]213 ; CHECK: %[[#mul:]] = OpIMul %[[#int_32]] %[[#arg0]] %[[#arg1]]214 ; CHECK: OpIAdd %[[#int_32]] %[[#mul]] %[[#arg2]]215 %3 = mul nuw i32 %p0, %p1216 %4 = add nuw i32 %3, %p2217 ret i32 %4218}219 220define spir_func noundef <2 x i32> @test_mad_uint2(<2 x i32> noundef %p0, <2 x i32> noundef %p1, <2 x i32> noundef %p2) {221entry:222 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]223 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]224 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]225 ; CHECK: %[[#mul:]] = OpIMul %[[#vec2_32]] %[[#arg0]] %[[#arg1]]226 ; CHECK: OpIAdd %[[#vec2_32]] %[[#mul]] %[[#arg2]]227 %3 = mul nuw <2 x i32> %p0, %p1228 %4 = add nuw <2 x i32> %3, %p2229 ret <2 x i32> %4230}231 232define spir_func noundef <3 x i32> @test_mad_uint3(<3 x i32> noundef %p0, <3 x i32> noundef %p1, <3 x i32> noundef %p2) {233entry:234 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]235 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]236 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]237 ; CHECK: %[[#mul:]] = OpIMul %[[#vec3_32]] %[[#arg0]] %[[#arg1]]238 ; CHECK: OpIAdd %[[#vec3_32]] %[[#mul]] %[[#arg2]]239 %3 = mul nuw <3 x i32> %p0, %p1240 %4 = add nuw <3 x i32> %3, %p2241 ret <3 x i32> %4242}243 244define spir_func noundef <4 x i32> @test_mad_uint4(<4 x i32> noundef %p0, <4 x i32> noundef %p1, <4 x i32> noundef %p2) {245entry:246 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]247 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]248 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]249 ; CHECK: %[[#mul:]] = OpIMul %[[#vec4_32]] %[[#arg0]] %[[#arg1]]250 ; CHECK: OpIAdd %[[#vec4_32]] %[[#mul]] %[[#arg2]]251 %3 = mul nuw <4 x i32> %p0, %p1252 %4 = add nuw <4 x i32> %3, %p2253 ret <4 x i32> %4254}255 256define spir_func noundef i64 @test_mad_uint64_t(i64 noundef %p0, i64 noundef %p1, i64 noundef %p2) {257entry:258 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]259 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]260 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]261 ; CHECK: %[[#mul:]] = OpIMul %[[#int_64]] %[[#arg0]] %[[#arg1]]262 ; CHECK: OpIAdd %[[#int_64]] %[[#mul]] %[[#arg2]]263 %3 = mul nuw i64 %p0, %p1264 %4 = add nuw i64 %3, %p2265 ret i64 %4266}267 268define spir_func noundef <2 x i64> @test_mad_uint64_t2(<2 x i64> noundef %p0, <2 x i64> noundef %p1, <2 x i64> noundef %p2) {269entry:270 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]271 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]272 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]273 ; CHECK: %[[#mul:]] = OpIMul %[[#vec2_64]] %[[#arg0]] %[[#arg1]]274 ; CHECK: OpIAdd %[[#vec2_64]] %[[#mul]] %[[#arg2]]275 %3 = mul nuw <2 x i64> %p0, %p1276 %4 = add nuw <2 x i64> %3, %p2277 ret <2 x i64> %4278}279 280define spir_func noundef <3 x i64> @test_mad_uint64_t3(<3 x i64> noundef %p0, <3 x i64> noundef %p1, <3 x i64> noundef %p2) {281entry:282 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]283 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]284 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]285 ; CHECK: %[[#mul:]] = OpIMul %[[#vec3_64]] %[[#arg0]] %[[#arg1]]286 ; CHECK: OpIAdd %[[#vec3_64]] %[[#mul]] %[[#arg2]]287 %3 = mul nuw <3 x i64> %p0, %p1288 %4 = add nuw <3 x i64> %3, %p2289 ret <3 x i64> %4290}291 292define spir_func noundef <4 x i64> @test_mad_uint64_t4(<4 x i64> noundef %p0, <4 x i64> noundef %p1, <4 x i64> noundef %p2) {293entry:294 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]295 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]296 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]297 ; CHECK: %[[#mul:]] = OpIMul %[[#vec4_64]] %[[#arg0]] %[[#arg1]]298 ; CHECK: OpIAdd %[[#vec4_64]] %[[#mul]] %[[#arg2]]299 %3 = mul nuw <4 x i64> %p0, %p1300 %4 = add nuw <4 x i64> %3, %p2301 ret <4 x i64> %4302}303