259 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py2; RUN: opt < %s -mtriple=riscv64 -mattr=+v,+f,+short-forward-branch-ialu -passes="print<cost-model>" -cost-kind=throughput 2>&1 -disable-output | FileCheck %s --check-prefixes=SFB643; RUN: opt < %s -mtriple=riscv64 -mattr=+v,+f -passes="print<cost-model>" -cost-kind=throughput 2>&1 -disable-output | FileCheck %s --check-prefixes=RV644 5define i32 @icmp-iselect(i64 %ca, i64 %cb, i32 %a, i32 %b) {6; SFB64-LABEL: 'icmp-iselect'7; SFB64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %cmp1 = icmp slt i64 %ca, %cb8; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select1 = select i1 %cmp1, i32 %a, i32 %b9; SFB64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %select110;11; RV64-LABEL: 'icmp-iselect'12; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cmp1 = icmp slt i64 %ca, %cb13; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select1 = select i1 %cmp1, i32 %a, i32 %b14; RV64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %select115;16 %cmp1 = icmp slt i64 %ca, %cb17 %select1 = select i1 %cmp1, i32 %a, i32 %b18 ret i32 %select119}20 21define i32 @icmp-iselects(i64 %ca, i64 %cb, i32 %a, i32 %b, i32 %c) {22; SFB64-LABEL: 'icmp-iselects'23; SFB64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %cmp1 = icmp slt i64 %ca, %cb24; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select1 = select i1 %cmp1, i32 %a, i32 %b25; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select2 = select i1 %cmp1, i32 %a, i32 %c26; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ret = add i32 %select1, %select227; SFB64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %ret28;29; RV64-LABEL: 'icmp-iselects'30; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cmp1 = icmp slt i64 %ca, %cb31; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select1 = select i1 %cmp1, i32 %a, i32 %b32; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select2 = select i1 %cmp1, i32 %a, i32 %c33; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ret = add i32 %select1, %select234; RV64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %ret35;36 %cmp1 = icmp slt i64 %ca, %cb37 %select1 = select i1 %cmp1, i32 %a, i32 %b38 %select2 = select i1 %cmp1, i32 %a, i32 %c39 %ret = add i32 %select1, %select240 ret i32 %ret41}42 43define i32 @icmp-ifselects(i64 %ca, i64 %cb, i32 %a, i32 %b, float %c, float %d) {44; SFB64-LABEL: 'icmp-ifselects'45; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cmp1 = icmp slt i64 %ca, %cb46; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select1 = select i1 %cmp1, i32 %a, i32 %b47; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select2 = select i1 %cmp1, float %c, float %d48; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %selectint = fptosi float %select2 to i3249; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ret = add i32 %select1, %selectint50; SFB64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %ret51;52; RV64-LABEL: 'icmp-ifselects'53; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cmp1 = icmp slt i64 %ca, %cb54; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select1 = select i1 %cmp1, i32 %a, i32 %b55; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select2 = select i1 %cmp1, float %c, float %d56; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %selectint = fptosi float %select2 to i3257; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ret = add i32 %select1, %selectint58; RV64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %ret59;60 %cmp1 = icmp slt i64 %ca, %cb61 %select1 = select i1 %cmp1, i32 %a, i32 %b62 %select2 = select i1 %cmp1, float %c, float %d63 %selectint = fptosi float %select2 to i3264 %ret = add i32 %select1, %selectint65 ret i32 %ret66}67 68define i32 @constant-icmp-iselect(i64 %ca, i64 %cb, i32 %a) {69; SFB64-LABEL: 'constant-icmp-iselect'70; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cmp1 = icmp slt i64 %ca, %cb71; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select1 = select i1 %cmp1, i32 %a, i32 772; SFB64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %select173;74; RV64-LABEL: 'constant-icmp-iselect'75; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cmp1 = icmp slt i64 %ca, %cb76; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select1 = select i1 %cmp1, i32 %a, i32 777; RV64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %select178;79 %cmp1 = icmp slt i64 %ca, %cb80 %select1 = select i1 %cmp1, i32 %a, i32 781 ret i32 %select182}83 84define i32 @fcmp-iselect(float %ca, float %cb, i32 %a, i32 %b) {85; SFB64-LABEL: 'fcmp-iselect'86; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %fcmp1 = fcmp ogt float %ca, %cb87; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select1 = select i1 %fcmp1, i32 %a, i32 %b88; SFB64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %select189;90; RV64-LABEL: 'fcmp-iselect'91; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %fcmp1 = fcmp ogt float %ca, %cb92; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select1 = select i1 %fcmp1, i32 %a, i32 %b93; RV64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %select194;95 %fcmp1 = fcmp ogt float %ca, %cb96 %select1 = select i1 %fcmp1, i32 %a, i32 %b97 ret i32 %select198}99 100define float @fcmp-fselect(float %ca, float %cb, float %a, float %b) {101; SFB64-LABEL: 'fcmp-fselect'102; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %fcmp1 = fcmp ogt float %ca, %cb103; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %fselect1 = select i1 %fcmp1, float %a, float %b104; SFB64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret float %fselect1105;106; RV64-LABEL: 'fcmp-fselect'107; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %fcmp1 = fcmp ogt float %ca, %cb108; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %fselect1 = select i1 %fcmp1, float %a, float %b109; RV64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret float %fselect1110;111 %fcmp1 = fcmp ogt float %ca, %cb112 %fselect1 = select i1 %fcmp1, float %a, float %b113 ret float %fselect1114}115 116define float @icmp-fselect(i64 %ca, i64 %cb, float %a, float %b) {117; SFB64-LABEL: 'icmp-fselect'118; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %icmp1 = icmp slt i64 %ca, %cb119; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %fselect1 = select i1 %icmp1, float %a, float %b120; SFB64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret float %fselect1121;122; RV64-LABEL: 'icmp-fselect'123; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %icmp1 = icmp slt i64 %ca, %cb124; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %fselect1 = select i1 %icmp1, float %a, float %b125; RV64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret float %fselect1126;127 %icmp1 = icmp slt i64 %ca, %cb128 %fselect1 = select i1 %icmp1, float %a, float %b129 ret float %fselect1130}131 132define <2 x i32> @vector-icmp-vector-iselect(<2 x i32> %ca, <2 x i32> %cb, <2 x i32> %a, <2 x i32> %b) {133; SFB64-LABEL: 'vector-icmp-vector-iselect'134; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %icmp = icmp slt <2 x i32> %ca, %cb135; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select1 = select <2 x i1> %icmp, <2 x i32> %a, <2 x i32> %b136; SFB64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i32> %select1137;138; RV64-LABEL: 'vector-icmp-vector-iselect'139; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %icmp = icmp slt <2 x i32> %ca, %cb140; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select1 = select <2 x i1> %icmp, <2 x i32> %a, <2 x i32> %b141; RV64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i32> %select1142;143 %icmp = icmp slt <2 x i32> %ca, %cb144 %select1 = select <2 x i1> %icmp, <2 x i32> %a, <2 x i32> %b145 ret <2 x i32> %select1146}147 148define <2 x i32> @vector-fcmp-vector-iselect(<2 x float> %ca, <2 x float> %cb, <2 x i32> %a, <2 x i32> %b) {149; SFB64-LABEL: 'vector-fcmp-vector-iselect'150; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %fcmp1 = fcmp ogt <2 x float> %ca, %cb151; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select1 = select <2 x i1> %fcmp1, <2 x i32> %a, <2 x i32> %b152; SFB64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i32> %select1153;154; RV64-LABEL: 'vector-fcmp-vector-iselect'155; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %fcmp1 = fcmp ogt <2 x float> %ca, %cb156; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select1 = select <2 x i1> %fcmp1, <2 x i32> %a, <2 x i32> %b157; RV64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i32> %select1158;159 %fcmp1 = fcmp ogt <2 x float> %ca, %cb160 %select1 = select <2 x i1> %fcmp1, <2 x i32> %a, <2 x i32> %b161 ret <2 x i32> %select1162}163 164define <2 x float> @vector-fcmp-vector-fselect(<2 x float> %ca, <2 x float> %cb, <2 x float> %a, <2 x float> %b) {165; SFB64-LABEL: 'vector-fcmp-vector-fselect'166; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %fcmp1 = fcmp ogt <2 x float> %ca, %cb167; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select1 = select <2 x i1> %fcmp1, <2 x float> %a, <2 x float> %b168; SFB64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x float> %select1169;170; RV64-LABEL: 'vector-fcmp-vector-fselect'171; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %fcmp1 = fcmp ogt <2 x float> %ca, %cb172; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select1 = select <2 x i1> %fcmp1, <2 x float> %a, <2 x float> %b173; RV64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x float> %select1174;175 %fcmp1 = fcmp ogt <2 x float> %ca, %cb176 %select1 = select <2 x i1> %fcmp1, <2 x float> %a, <2 x float> %b177 ret <2 x float> %select1178}179 180define <2 x float> @vector-icmp-vector-fselect(<2 x i32> %ca, <2 x i32> %cb, <2 x float> %a, <2 x float> %b) {181; SFB64-LABEL: 'vector-icmp-vector-fselect'182; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %icmp1 = icmp slt <2 x i32> %ca, %cb183; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select1 = select <2 x i1> %icmp1, <2 x float> %a, <2 x float> %b184; SFB64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x float> %select1185;186; RV64-LABEL: 'vector-icmp-vector-fselect'187; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %icmp1 = icmp slt <2 x i32> %ca, %cb188; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %select1 = select <2 x i1> %icmp1, <2 x float> %a, <2 x float> %b189; RV64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x float> %select1190;191 %icmp1 = icmp slt <2 x i32> %ca, %cb192 %select1 = select <2 x i1> %icmp1, <2 x float> %a, <2 x float> %b193 ret <2 x float> %select1194}195 196define <2 x float> @icmp-vector-fselect(i1 %ca, i1 %cb, <2 x float> %a, <2 x float> %b) {197; SFB64-LABEL: 'icmp-vector-fselect'198; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %icmp1 = icmp slt i1 %ca, %cb199; SFB64-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %select1 = select i1 %icmp1, <2 x float> %a, <2 x float> %b200; SFB64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x float> %select1201;202; RV64-LABEL: 'icmp-vector-fselect'203; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %icmp1 = icmp slt i1 %ca, %cb204; RV64-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %select1 = select i1 %icmp1, <2 x float> %a, <2 x float> %b205; RV64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x float> %select1206;207 %icmp1 = icmp slt i1 %ca, %cb208 %select1 = select i1 %icmp1, <2 x float> %a, <2 x float> %b209 ret <2 x float> %select1210}211 212define <2 x i32> @icmp-vector-iselect(i1 %ca, i1 %cb, <2 x i32> %a, <2 x i32> %b) {213; SFB64-LABEL: 'icmp-vector-iselect'214; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %icmp1 = icmp slt i1 %ca, %cb215; SFB64-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %select1 = select i1 %icmp1, <2 x i32> %a, <2 x i32> %b216; SFB64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i32> %select1217;218; RV64-LABEL: 'icmp-vector-iselect'219; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %icmp1 = icmp slt i1 %ca, %cb220; RV64-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %select1 = select i1 %icmp1, <2 x i32> %a, <2 x i32> %b221; RV64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i32> %select1222;223 %icmp1 = icmp slt i1 %ca, %cb224 %select1 = select i1 %icmp1, <2 x i32> %a, <2 x i32> %b225 ret <2 x i32> %select1226}227 228define <2 x float> @fcmp-vector-fselect(float %ca, float %cb, <2 x float> %a, <2 x float> %b) {229; SFB64-LABEL: 'fcmp-vector-fselect'230; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %fcmp1 = fcmp ogt float %ca, %cb231; SFB64-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %select1 = select i1 %fcmp1, <2 x float> %a, <2 x float> %b232; SFB64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x float> %select1233;234; RV64-LABEL: 'fcmp-vector-fselect'235; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %fcmp1 = fcmp ogt float %ca, %cb236; RV64-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %select1 = select i1 %fcmp1, <2 x float> %a, <2 x float> %b237; RV64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x float> %select1238;239 %fcmp1 = fcmp ogt float %ca, %cb240 %select1 = select i1 %fcmp1, <2 x float> %a, <2 x float> %b241 ret <2 x float> %select1242}243 244define <2 x i32> @fcmp-vector-iselect(float %ca, float %cb, <2 x i32> %a, <2 x i32> %b) {245; SFB64-LABEL: 'fcmp-vector-iselect'246; SFB64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %fcmp1 = fcmp ogt float %ca, %cb247; SFB64-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %select1 = select i1 %fcmp1, <2 x i32> %a, <2 x i32> %b248; SFB64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i32> %select1249;250; RV64-LABEL: 'fcmp-vector-iselect'251; RV64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %fcmp1 = fcmp ogt float %ca, %cb252; RV64-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %select1 = select i1 %fcmp1, <2 x i32> %a, <2 x i32> %b253; RV64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i32> %select1254;255 %fcmp1 = fcmp ogt float %ca, %cb256 %select1 = select i1 %fcmp1, <2 x i32> %a, <2 x i32> %b257 ret <2 x i32> %select1258}259