1589e6bcbSLuke Lau; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 2 2c501aa88SPhilip Reames; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv32 -mattr=+v | FileCheck --check-prefixes=CHECK,RV32 %s 3c501aa88SPhilip Reames; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+v | FileCheck --check-prefixes=CHECK,RV64 %s 4a9d9616cSLuke Lau 5a9d9616cSLuke Lau; The mask here interleaves (%v1, %v0), not (%v0, %v1): it should still be cheap. 6a9d9616cSLuke Laudefine <4 x i8> @interleave2_v2i8(<2 x i8> %v0, <2 x i8> %v1) { 7a9d9616cSLuke Lau; CHECK-LABEL: 'interleave2_v2i8' 8f23ea4cbSLuke Lau; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %concat = shufflevector <2 x i8> %v0, <2 x i8> %v1, <4 x i32> <i32 0, i32 1, i32 2, i32 3> 9a9d9616cSLuke Lau; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = shufflevector <4 x i8> %concat, <4 x i8> poison, <4 x i32> <i32 2, i32 0, i32 3, i32 1> 100a5d52a7SSergey Kachkov; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i8> %res 11a9d9616cSLuke Lau; 12a9d9616cSLuke Lau %concat = shufflevector <2 x i8> %v0, <2 x i8> %v1, <4 x i32> <i32 0, i32 1, i32 2, i32 3> 13a9d9616cSLuke Lau %res = shufflevector <4 x i8> %concat, <4 x i8> poison, <4 x i32> <i32 2, i32 0, i32 3, i32 1> 14a9d9616cSLuke Lau ret <4 x i8> %res 15a9d9616cSLuke Lau} 16a9d9616cSLuke Lau 17589e6bcbSLuke Laudefine <8 x i8> @interleave2_v8i8(<4 x i8> %v0, <4 x i8> %v1) { 18589e6bcbSLuke Lau; CHECK-LABEL: 'interleave2_v8i8' 19f23ea4cbSLuke Lau; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %concat = shufflevector <4 x i8> %v0, <4 x i8> %v1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> 20c417266dSLuke Lau; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %res = shufflevector <8 x i8> %concat, <8 x i8> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7> 210a5d52a7SSergey Kachkov; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i8> %res 22589e6bcbSLuke Lau; 23589e6bcbSLuke Lau %concat = shufflevector <4 x i8> %v0, <4 x i8> %v1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> 24589e6bcbSLuke Lau %res = shufflevector <8 x i8> %concat, <8 x i8> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7> 25589e6bcbSLuke Lau ret <8 x i8> %res 26589e6bcbSLuke Lau} 27589e6bcbSLuke Lau 28589e6bcbSLuke Laudefine <8 x i32> @interleave2_v8i32(<4 x i32> %v0, <4 x i32> %v1) { 29589e6bcbSLuke Lau; CHECK-LABEL: 'interleave2_v8i32' 30f23ea4cbSLuke Lau; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %concat = shufflevector <4 x i32> %v0, <4 x i32> %v1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> 31c417266dSLuke Lau; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %res = shufflevector <8 x i32> %concat, <8 x i32> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7> 320a5d52a7SSergey Kachkov; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %res 33589e6bcbSLuke Lau; 34589e6bcbSLuke Lau %concat = shufflevector <4 x i32> %v0, <4 x i32> %v1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> 35589e6bcbSLuke Lau %res = shufflevector <8 x i32> %concat, <8 x i32> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7> 36589e6bcbSLuke Lau ret <8 x i32> %res 37589e6bcbSLuke Lau} 38589e6bcbSLuke Lau 39589e6bcbSLuke Lau; Should be expensive on RV32 because it can't widen 40589e6bcbSLuke Laudefine <8 x i64> @interleave2_v8i64(<4 x i64> %v0, <4 x i64> %v1) { 41c501aa88SPhilip Reames; RV32-LABEL: 'interleave2_v8i64' 42c501aa88SPhilip Reames; RV32-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %concat = shufflevector <4 x i64> %v0, <4 x i64> %v1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> 437cc6b80dSPhilip Reames; RV32-NEXT: Cost Model: Found an estimated cost of 19 for instruction: %res = shufflevector <8 x i64> %concat, <8 x i64> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7> 440a5d52a7SSergey Kachkov; RV32-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i64> %res 45c501aa88SPhilip Reames; 46c501aa88SPhilip Reames; RV64-LABEL: 'interleave2_v8i64' 47c501aa88SPhilip Reames; RV64-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %concat = shufflevector <4 x i64> %v0, <4 x i64> %v1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> 487cc6b80dSPhilip Reames; RV64-NEXT: Cost Model: Found an estimated cost of 22 for instruction: %res = shufflevector <8 x i64> %concat, <8 x i64> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7> 490a5d52a7SSergey Kachkov; RV64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i64> %res 50589e6bcbSLuke Lau; 51589e6bcbSLuke Lau %concat = shufflevector <4 x i64> %v0, <4 x i64> %v1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> 52589e6bcbSLuke Lau %res = shufflevector <8 x i64> %concat, <8 x i64> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7> 53589e6bcbSLuke Lau ret <8 x i64> %res 54589e6bcbSLuke Lau} 55589e6bcbSLuke Lau 56589e6bcbSLuke Lau; TODO: getInstructionCost doesn't call getShuffleCost here because the shuffle changes length 57589e6bcbSLuke Laudefine {<4 x i8>, <4 x i8>} @deinterleave_2(<8 x i8> %v) { 58589e6bcbSLuke Lau; CHECK-LABEL: 'deinterleave_2' 59*55304d0dSSimon Pilgrim; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v0 = shufflevector <8 x i8> %v, <8 x i8> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6> 60*55304d0dSSimon Pilgrim; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v1 = shufflevector <8 x i8> %v, <8 x i8> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7> 61589e6bcbSLuke Lau; CHECK-NEXT: Cost Model: Found an estimated cost of -1 for instruction: %res0 = insertvalue { <4 x i8>, <4 x i8> } poison, <4 x i8> %v0, 0 62589e6bcbSLuke Lau; CHECK-NEXT: Cost Model: Found an estimated cost of -1 for instruction: %res1 = insertvalue { <4 x i8>, <4 x i8> } %res0, <4 x i8> %v1, 1 630a5d52a7SSergey Kachkov; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret { <4 x i8>, <4 x i8> } %res1 64589e6bcbSLuke Lau; 65589e6bcbSLuke Lau %v0 = shufflevector <8 x i8> %v, <8 x i8> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6> 66589e6bcbSLuke Lau %v1 = shufflevector <8 x i8> %v, <8 x i8> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7> 67589e6bcbSLuke Lau %res0 = insertvalue {<4 x i8>, <4 x i8>} poison, <4 x i8> %v0, 0 68589e6bcbSLuke Lau %res1 = insertvalue {<4 x i8>, <4 x i8>} %res0, <4 x i8> %v1, 1 69589e6bcbSLuke Lau ret {<4 x i8>, <4 x i8>} %res1 70589e6bcbSLuke Lau} 71