|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | +; RUN: opt -passes='lower-matrix-intrinsics' -S < %s | FileCheck %s |
| 3 | + |
| 4 | +define float @extract_static(ptr %in, ptr %out) { |
| 5 | +; CHECK-LABEL: @extract_static( |
| 6 | +; CHECK-NEXT: [[COL_LOAD:%.*]] = load <2 x float>, ptr [[IN:%.*]], align 16 |
| 7 | +; CHECK-NEXT: [[VEC_GEP:%.*]] = getelementptr float, ptr [[IN]], i64 2 |
| 8 | +; CHECK-NEXT: [[COL_LOAD1:%.*]] = load <2 x float>, ptr [[VEC_GEP]], align 8 |
| 9 | +; CHECK-NEXT: [[EXTRACT:%.*]] = extractelement <2 x float> [[COL_LOAD1]], i32 1 |
| 10 | +; CHECK-NEXT: ret float [[EXTRACT]] |
| 11 | +; |
| 12 | + %inv = load <4 x float>, ptr %in |
| 13 | + %invt = call <4 x float> @llvm.matrix.transpose(<4 x float> %inv, i32 2, i32 2) |
| 14 | + %invtt = call <4 x float> @llvm.matrix.transpose(<4 x float> %invt, i32 2, i32 2) |
| 15 | + %extract = extractelement <4 x float> %invtt, i32 3 |
| 16 | + ret float %extract |
| 17 | +} |
| 18 | + |
| 19 | +define float @extract_static_outofbounds(ptr %in, ptr %out) { |
| 20 | +; CHECK-LABEL: @extract_static_outofbounds( |
| 21 | +; CHECK-NEXT: [[COL_LOAD:%.*]] = load <2 x float>, ptr [[IN:%.*]], align 16 |
| 22 | +; CHECK-NEXT: [[VEC_GEP:%.*]] = getelementptr float, ptr [[IN]], i64 2 |
| 23 | +; CHECK-NEXT: [[COL_LOAD1:%.*]] = load <2 x float>, ptr [[VEC_GEP]], align 8 |
| 24 | +; CHECK-NEXT: ret float poison |
| 25 | +; |
| 26 | + %inv = load <4 x float>, ptr %in |
| 27 | + %invt = call <4 x float> @llvm.matrix.transpose(<4 x float> %inv, i32 2, i32 2) |
| 28 | + %invtt = call <4 x float> @llvm.matrix.transpose(<4 x float> %invt, i32 2, i32 2) |
| 29 | + %extract = extractelement <4 x float> %invtt, i32 5 |
| 30 | + ret float %extract |
| 31 | +} |
| 32 | + |
| 33 | +define float @extract_dynamic(ptr %in, i32 %idx, ptr %out) { |
| 34 | +; CHECK-LABEL: @extract_dynamic( |
| 35 | +; CHECK-NEXT: [[COL_LOAD:%.*]] = load <2 x float>, ptr [[IN:%.*]], align 16 |
| 36 | +; CHECK-NEXT: [[VEC_GEP:%.*]] = getelementptr float, ptr [[IN]], i64 2 |
| 37 | +; CHECK-NEXT: [[COL_LOAD1:%.*]] = load <2 x float>, ptr [[VEC_GEP]], align 8 |
| 38 | +; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <2 x float> [[COL_LOAD]], <2 x float> [[COL_LOAD1]], <4 x i32> <i32 0, i32 1, i32 2, i32 3> |
| 39 | +; CHECK-NEXT: [[EXTRACT:%.*]] = extractelement <4 x float> [[TMP1]], i32 [[IDX:%.*]] |
| 40 | +; CHECK-NEXT: ret float [[EXTRACT]] |
| 41 | +; |
| 42 | + %inv = load <4 x float>, ptr %in |
| 43 | + %invt = call <4 x float> @llvm.matrix.transpose(<4 x float> %inv, i32 2, i32 2) |
| 44 | + %invtt = call <4 x float> @llvm.matrix.transpose(<4 x float> %invt, i32 2, i32 2) |
| 45 | + %extract = extractelement <4 x float> %invtt, i32 %idx |
| 46 | + ret float %extract |
| 47 | +} |
0 commit comments