52 lines · c
1// RUN: %clang -emit-llvm -S -fenable-matrix -mllvm -disable-llvm-optzns %s -o - | FileCheck %s2// UNSUPPORTED: target={{.*}}-zos{{.*}}3 4typedef float fx2x2_t __attribute__((matrix_type(2, 2)));5typedef int ix2x2_t __attribute__((matrix_type(2, 2)));6 7fx2x2_t fp_matrix_contract(fx2x2_t a, fx2x2_t b, float c, float d) {8// CHECK: call contract <4 x float> @llvm.matrix.multiply.v4f32.v4f32.v4f329// CHECK: fdiv contract <4 x float>10// CHECK: fmul contract <4 x float>11#pragma clang fp contract(fast)12 return (a * b / c) * d;13}14 15fx2x2_t fp_matrix_reassoc(fx2x2_t a, fx2x2_t b, fx2x2_t c) {16// CHECK: fadd reassoc <4 x float>17// CHECK: fsub reassoc <4 x float>18#pragma clang fp reassociate(on)19 return a + b - c;20}21 22fx2x2_t fp_matrix_ops(fx2x2_t a, fx2x2_t b, fx2x2_t c) {23// CHECK: call reassoc contract <4 x float> @llvm.matrix.multiply.v4f32.v4f32.v4f3224// CHECK: fadd reassoc contract <4 x float>25#pragma clang fp contract(fast) reassociate(on)26 return a * b + c;27}28 29fx2x2_t fp_matrix_compound_ops(fx2x2_t a, fx2x2_t b, fx2x2_t c, fx2x2_t d,30 float e, float f) {31// CHECK: call reassoc contract <4 x float> @llvm.matrix.multiply.v4f32.v4f32.v4f3232// CHECK: fadd reassoc contract <4 x float>33// CHECK: fsub reassoc contract <4 x float>34// CHECK: fmul reassoc contract <4 x float>35// CHECK: fdiv reassoc contract <4 x float>36#pragma clang fp contract(fast) reassociate(on)37 a *= b;38 a += c;39 a -= d;40 a *= e;41 a /= f;42 43 return a;44}45 46ix2x2_t int_matrix_ops(ix2x2_t a, ix2x2_t b, ix2x2_t c) {47// CHECK: call <4 x i32> @llvm.matrix.multiply.v4i32.v4i32.v4i3248// CHECK: add <4 x i32>49#pragma clang fp contract(fast) reassociate(on)50 return a * b + c;51}52