1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -lower-matrix-intrinsics -matrix-default-layout=row-major -S < %s | FileCheck --check-prefix=RM %s 3 4define <8 x double> @transpose(<8 x double> %a) { 5; RM-LABEL: @transpose( 6; RM-NEXT: entry: 7; RM-NEXT: [[SPLIT:%.*]] = shufflevector <8 x double> [[A:%.*]], <8 x double> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3> 8; RM-NEXT: [[SPLIT1:%.*]] = shufflevector <8 x double> [[A]], <8 x double> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7> 9; RM-NEXT: [[TMP0:%.*]] = extractelement <4 x double> [[SPLIT]], i64 0 10; RM-NEXT: [[TMP1:%.*]] = insertelement <2 x double> undef, double [[TMP0]], i64 0 11; RM-NEXT: [[TMP2:%.*]] = extractelement <4 x double> [[SPLIT1]], i64 0 12; RM-NEXT: [[TMP3:%.*]] = insertelement <2 x double> [[TMP1]], double [[TMP2]], i64 1 13; RM-NEXT: [[TMP4:%.*]] = extractelement <4 x double> [[SPLIT]], i64 1 14; RM-NEXT: [[TMP5:%.*]] = insertelement <2 x double> undef, double [[TMP4]], i64 0 15; RM-NEXT: [[TMP6:%.*]] = extractelement <4 x double> [[SPLIT1]], i64 1 16; RM-NEXT: [[TMP7:%.*]] = insertelement <2 x double> [[TMP5]], double [[TMP6]], i64 1 17; RM-NEXT: [[TMP8:%.*]] = extractelement <4 x double> [[SPLIT]], i64 2 18; RM-NEXT: [[TMP9:%.*]] = insertelement <2 x double> undef, double [[TMP8]], i64 0 19; RM-NEXT: [[TMP10:%.*]] = extractelement <4 x double> [[SPLIT1]], i64 2 20; RM-NEXT: [[TMP11:%.*]] = insertelement <2 x double> [[TMP9]], double [[TMP10]], i64 1 21; RM-NEXT: [[TMP12:%.*]] = extractelement <4 x double> [[SPLIT]], i64 3 22; RM-NEXT: [[TMP13:%.*]] = insertelement <2 x double> undef, double [[TMP12]], i64 0 23; RM-NEXT: [[TMP14:%.*]] = extractelement <4 x double> [[SPLIT1]], i64 3 24; RM-NEXT: [[TMP15:%.*]] = insertelement <2 x double> [[TMP13]], double [[TMP14]], i64 1 25; RM-NEXT: [[TMP16:%.*]] = shufflevector <2 x double> [[TMP3]], <2 x double> [[TMP7]], <4 x i32> <i32 0, i32 1, i32 2, i32 3> 26; RM-NEXT: [[TMP17:%.*]] = shufflevector <2 x double> [[TMP11]], <2 x double> [[TMP15]], <4 x i32> <i32 0, i32 1, i32 2, i32 3> 27; RM-NEXT: [[TMP18:%.*]] = shufflevector <4 x double> [[TMP16]], <4 x double> [[TMP17]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> 28; RM-NEXT: ret <8 x double> [[TMP18]] 29; 30entry: 31 %c = call <8 x double> @llvm.matrix.transpose(<8 x double> %a, i32 2, i32 4) 32 ret <8 x double> %c 33} 34 35declare <8 x double> @llvm.matrix.transpose(<8 x double>, i32, i32) 36 37define <8 x double> @transpose_single_column(<8 x double> %a) { 38; RM-LABEL: @transpose_single_column( 39; RM-NEXT: entry: 40; RM-NEXT: [[SPLIT:%.*]] = shufflevector <8 x double> [[A:%.*]], <8 x double> undef, <1 x i32> zeroinitializer 41; RM-NEXT: [[SPLIT1:%.*]] = shufflevector <8 x double> [[A]], <8 x double> undef, <1 x i32> <i32 1> 42; RM-NEXT: [[SPLIT2:%.*]] = shufflevector <8 x double> [[A]], <8 x double> undef, <1 x i32> <i32 2> 43; RM-NEXT: [[SPLIT3:%.*]] = shufflevector <8 x double> [[A]], <8 x double> undef, <1 x i32> <i32 3> 44; RM-NEXT: [[SPLIT4:%.*]] = shufflevector <8 x double> [[A]], <8 x double> undef, <1 x i32> <i32 4> 45; RM-NEXT: [[SPLIT5:%.*]] = shufflevector <8 x double> [[A]], <8 x double> undef, <1 x i32> <i32 5> 46; RM-NEXT: [[SPLIT6:%.*]] = shufflevector <8 x double> [[A]], <8 x double> undef, <1 x i32> <i32 6> 47; RM-NEXT: [[SPLIT7:%.*]] = shufflevector <8 x double> [[A]], <8 x double> undef, <1 x i32> <i32 7> 48; RM-NEXT: [[TMP0:%.*]] = extractelement <1 x double> [[SPLIT]], i64 0 49; RM-NEXT: [[TMP1:%.*]] = insertelement <8 x double> undef, double [[TMP0]], i64 0 50; RM-NEXT: [[TMP2:%.*]] = extractelement <1 x double> [[SPLIT1]], i64 0 51; RM-NEXT: [[TMP3:%.*]] = insertelement <8 x double> [[TMP1]], double [[TMP2]], i64 1 52; RM-NEXT: [[TMP4:%.*]] = extractelement <1 x double> [[SPLIT2]], i64 0 53; RM-NEXT: [[TMP5:%.*]] = insertelement <8 x double> [[TMP3]], double [[TMP4]], i64 2 54; RM-NEXT: [[TMP6:%.*]] = extractelement <1 x double> [[SPLIT3]], i64 0 55; RM-NEXT: [[TMP7:%.*]] = insertelement <8 x double> [[TMP5]], double [[TMP6]], i64 3 56; RM-NEXT: [[TMP8:%.*]] = extractelement <1 x double> [[SPLIT4]], i64 0 57; RM-NEXT: [[TMP9:%.*]] = insertelement <8 x double> [[TMP7]], double [[TMP8]], i64 4 58; RM-NEXT: [[TMP10:%.*]] = extractelement <1 x double> [[SPLIT5]], i64 0 59; RM-NEXT: [[TMP11:%.*]] = insertelement <8 x double> [[TMP9]], double [[TMP10]], i64 5 60; RM-NEXT: [[TMP12:%.*]] = extractelement <1 x double> [[SPLIT6]], i64 0 61; RM-NEXT: [[TMP13:%.*]] = insertelement <8 x double> [[TMP11]], double [[TMP12]], i64 6 62; RM-NEXT: [[TMP14:%.*]] = extractelement <1 x double> [[SPLIT7]], i64 0 63; RM-NEXT: [[TMP15:%.*]] = insertelement <8 x double> [[TMP13]], double [[TMP14]], i64 7 64; RM-NEXT: ret <8 x double> [[TMP15]] 65; 66entry: 67 %c = call <8 x double> @llvm.matrix.transpose(<8 x double> %a, i32 8, i32 1) 68 ret <8 x double> %c 69} 70 71declare <12 x double> @llvm.matrix.transpose.v12f64(<12 x double>, i32, i32) 72 73define <12 x double> @transpose_double_3x4(<12 x double> %a) { 74; RM-LABEL: @transpose_double_3x4( 75; RM-NEXT: entry: 76; RM-NEXT: [[SPLIT:%.*]] = shufflevector <12 x double> [[A:%.*]], <12 x double> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3> 77; RM-NEXT: [[SPLIT1:%.*]] = shufflevector <12 x double> [[A]], <12 x double> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7> 78; RM-NEXT: [[SPLIT2:%.*]] = shufflevector <12 x double> [[A]], <12 x double> undef, <4 x i32> <i32 8, i32 9, i32 10, i32 11> 79; RM-NEXT: [[TMP0:%.*]] = extractelement <4 x double> [[SPLIT]], i64 0 80; RM-NEXT: [[TMP1:%.*]] = insertelement <3 x double> undef, double [[TMP0]], i64 0 81; RM-NEXT: [[TMP2:%.*]] = extractelement <4 x double> [[SPLIT1]], i64 0 82; RM-NEXT: [[TMP3:%.*]] = insertelement <3 x double> [[TMP1]], double [[TMP2]], i64 1 83; RM-NEXT: [[TMP4:%.*]] = extractelement <4 x double> [[SPLIT2]], i64 0 84; RM-NEXT: [[TMP5:%.*]] = insertelement <3 x double> [[TMP3]], double [[TMP4]], i64 2 85; RM-NEXT: [[TMP6:%.*]] = extractelement <4 x double> [[SPLIT]], i64 1 86; RM-NEXT: [[TMP7:%.*]] = insertelement <3 x double> undef, double [[TMP6]], i64 0 87; RM-NEXT: [[TMP8:%.*]] = extractelement <4 x double> [[SPLIT1]], i64 1 88; RM-NEXT: [[TMP9:%.*]] = insertelement <3 x double> [[TMP7]], double [[TMP8]], i64 1 89; RM-NEXT: [[TMP10:%.*]] = extractelement <4 x double> [[SPLIT2]], i64 1 90; RM-NEXT: [[TMP11:%.*]] = insertelement <3 x double> [[TMP9]], double [[TMP10]], i64 2 91; RM-NEXT: [[TMP12:%.*]] = extractelement <4 x double> [[SPLIT]], i64 2 92; RM-NEXT: [[TMP13:%.*]] = insertelement <3 x double> undef, double [[TMP12]], i64 0 93; RM-NEXT: [[TMP14:%.*]] = extractelement <4 x double> [[SPLIT1]], i64 2 94; RM-NEXT: [[TMP15:%.*]] = insertelement <3 x double> [[TMP13]], double [[TMP14]], i64 1 95; RM-NEXT: [[TMP16:%.*]] = extractelement <4 x double> [[SPLIT2]], i64 2 96; RM-NEXT: [[TMP17:%.*]] = insertelement <3 x double> [[TMP15]], double [[TMP16]], i64 2 97; RM-NEXT: [[TMP18:%.*]] = extractelement <4 x double> [[SPLIT]], i64 3 98; RM-NEXT: [[TMP19:%.*]] = insertelement <3 x double> undef, double [[TMP18]], i64 0 99; RM-NEXT: [[TMP20:%.*]] = extractelement <4 x double> [[SPLIT1]], i64 3 100; RM-NEXT: [[TMP21:%.*]] = insertelement <3 x double> [[TMP19]], double [[TMP20]], i64 1 101; RM-NEXT: [[TMP22:%.*]] = extractelement <4 x double> [[SPLIT2]], i64 3 102; RM-NEXT: [[TMP23:%.*]] = insertelement <3 x double> [[TMP21]], double [[TMP22]], i64 2 103; RM-NEXT: [[TMP24:%.*]] = shufflevector <3 x double> [[TMP5]], <3 x double> [[TMP11]], <6 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5> 104; RM-NEXT: [[TMP25:%.*]] = shufflevector <3 x double> [[TMP17]], <3 x double> [[TMP23]], <6 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5> 105; RM-NEXT: [[TMP26:%.*]] = shufflevector <6 x double> [[TMP24]], <6 x double> [[TMP25]], <12 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11> 106; RM-NEXT: ret <12 x double> [[TMP26]] 107; 108entry: 109 %c = call <12 x double> @llvm.matrix.transpose.v12f64(<12 x double> %a, i32 3, i32 4) 110 ret <12 x double> %c 111} 112