335 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 22; RUN: llc < %s -mtriple=ve | FileCheck %s3 4;;; Test ‘llvm.smax.*’ intrinsic5;;;6;;; Syntax:7;;; This is an overloaded intrinsic. You can use @llvm.smax on any8;;; integer bit width or any vector of integer elements.9;;;10;;; declare i32 @llvm.smax.i32(i32 %a, i32 %b)11;;; declare <4 x i32> @llvm.smax.v4i32(<4 x i32> %a, <4 x i32> %b)12;;;13;;; Overview:14;;; Return the larger of %a and %b comparing the values as signed15;;; integers. Vector intrinsics operate on a per-element basis.16;;; The larger element of %a and %b at a given index is returned17;;; for that index.18;;;19;;; Arguments:20;;; The arguments (%a and %b) may be of any integer type or a vector21;;; with integer element type. The argument types must match each22;;; other, and the return type must match the argument type.23;;;24;;; Note:25;;; We test only i8/i16/i32/i64/i128.26 27; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn28define signext i8 @func_smax_var_i8(i8 noundef signext %0, i8 noundef signext %1) {29; CHECK-LABEL: func_smax_var_i8:30; CHECK: # %bb.0:31; CHECK-NEXT: maxs.w.sx %s0, %s0, %s132; CHECK-NEXT: adds.w.sx %s0, %s0, (0)133; CHECK-NEXT: b.l.t (, %s10)34 %3 = tail call i8 @llvm.smax.i8(i8 %0, i8 %1)35 ret i8 %336}37 38; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn39define signext i16 @func_smax_var_i16(i16 noundef signext %0, i16 noundef signext %1) {40; CHECK-LABEL: func_smax_var_i16:41; CHECK: # %bb.0:42; CHECK-NEXT: maxs.w.sx %s0, %s0, %s143; CHECK-NEXT: adds.w.sx %s0, %s0, (0)144; CHECK-NEXT: b.l.t (, %s10)45 %3 = tail call i16 @llvm.smax.i16(i16 %0, i16 %1)46 ret i16 %347}48 49; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn50define signext i32 @func_smax_var_i32(i32 noundef signext %0, i32 noundef signext %1) {51; CHECK-LABEL: func_smax_var_i32:52; CHECK: # %bb.0:53; CHECK-NEXT: maxs.w.sx %s0, %s0, %s154; CHECK-NEXT: adds.w.sx %s0, %s0, (0)155; CHECK-NEXT: b.l.t (, %s10)56 %3 = tail call i32 @llvm.smax.i32(i32 %0, i32 %1)57 ret i32 %358}59 60; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn61define i64 @func_smax_var_i64(i64 noundef %0, i64 noundef %1) {62; CHECK-LABEL: func_smax_var_i64:63; CHECK: # %bb.0:64; CHECK-NEXT: maxs.l %s0, %s0, %s165; CHECK-NEXT: b.l.t (, %s10)66 %3 = tail call i64 @llvm.smax.i64(i64 %0, i64 %1)67 ret i64 %368}69 70; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn71define i128 @func_smax_var_i128(i128 noundef %0, i128 noundef %1) {72; CHECK-LABEL: func_smax_var_i128:73; CHECK: # %bb.0:74; CHECK-NEXT: cmpu.l %s4, %s1, %s375; CHECK-NEXT: cmps.l %s5, %s1, %s376; CHECK-NEXT: or %s6, 0, (0)177; CHECK-NEXT: or %s7, 0, (0)178; CHECK-NEXT: cmov.l.gt %s7, (63)0, %s579; CHECK-NEXT: cmpu.l %s5, %s0, %s280; CHECK-NEXT: cmov.l.gt %s6, (63)0, %s581; CHECK-NEXT: cmov.l.eq %s7, %s6, %s482; CHECK-NEXT: cmov.w.ne %s2, %s0, %s783; CHECK-NEXT: cmov.w.ne %s3, %s1, %s784; CHECK-NEXT: or %s0, 0, %s285; CHECK-NEXT: or %s1, 0, %s386; CHECK-NEXT: b.l.t (, %s10)87 %3 = tail call i128 @llvm.smax.i128(i128 %0, i128 %1)88 ret i128 %389}90 91; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn92define signext i8 @func_smax_fore_zero_i8(i8 noundef signext %0) {93; CHECK-LABEL: func_smax_fore_zero_i8:94; CHECK: # %bb.0:95; CHECK-NEXT: maxs.w.sx %s0, 0, %s096; CHECK-NEXT: adds.w.zx %s0, %s0, (0)197; CHECK-NEXT: b.l.t (, %s10)98 %2 = tail call i8 @llvm.smax.i8(i8 %0, i8 0)99 ret i8 %2100}101 102; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn103define signext i16 @func_smax_fore_zero_i16(i16 noundef signext %0) {104; CHECK-LABEL: func_smax_fore_zero_i16:105; CHECK: # %bb.0:106; CHECK-NEXT: maxs.w.sx %s0, 0, %s0107; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1108; CHECK-NEXT: b.l.t (, %s10)109 %2 = tail call i16 @llvm.smax.i16(i16 %0, i16 0)110 ret i16 %2111}112 113; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn114define signext i32 @func_smax_fore_zero_i32(i32 noundef signext %0) {115; CHECK-LABEL: func_smax_fore_zero_i32:116; CHECK: # %bb.0:117; CHECK-NEXT: maxs.w.sx %s0, 0, %s0118; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1119; CHECK-NEXT: b.l.t (, %s10)120 %2 = tail call i32 @llvm.smax.i32(i32 %0, i32 0)121 ret i32 %2122}123 124; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn125define i64 @func_smax_fore_zero_i64(i64 noundef %0) {126; CHECK-LABEL: func_smax_fore_zero_i64:127; CHECK: # %bb.0:128; CHECK-NEXT: maxs.l %s0, 0, %s0129; CHECK-NEXT: b.l.t (, %s10)130 %2 = tail call i64 @llvm.smax.i64(i64 %0, i64 0)131 ret i64 %2132}133 134; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn135define i128 @func_smax_fore_zero_i128(i128 noundef %0) {136; CHECK-LABEL: func_smax_fore_zero_i128:137; CHECK: # %bb.0:138; CHECK-NEXT: cmov.l.lt %s0, (0)1, %s1139; CHECK-NEXT: maxs.l %s1, 0, %s1140; CHECK-NEXT: b.l.t (, %s10)141 %2 = tail call i128 @llvm.smax.i128(i128 %0, i128 0)142 ret i128 %2143}144 145; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn146define signext i8 @func_smax_back_zero_i8(i8 noundef signext %0) {147; CHECK-LABEL: func_smax_back_zero_i8:148; CHECK: # %bb.0:149; CHECK-NEXT: maxs.w.sx %s0, 0, %s0150; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1151; CHECK-NEXT: b.l.t (, %s10)152 %2 = tail call i8 @llvm.smax.i8(i8 %0, i8 0)153 ret i8 %2154}155 156; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn157define signext i16 @func_smax_back_zero_i16(i16 noundef signext %0) {158; CHECK-LABEL: func_smax_back_zero_i16:159; CHECK: # %bb.0:160; CHECK-NEXT: maxs.w.sx %s0, 0, %s0161; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1162; CHECK-NEXT: b.l.t (, %s10)163 %2 = tail call i16 @llvm.smax.i16(i16 %0, i16 0)164 ret i16 %2165}166 167; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn168define signext i32 @func_smax_back_zero_i32(i32 noundef signext %0) {169; CHECK-LABEL: func_smax_back_zero_i32:170; CHECK: # %bb.0:171; CHECK-NEXT: maxs.w.sx %s0, 0, %s0172; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1173; CHECK-NEXT: b.l.t (, %s10)174 %2 = tail call i32 @llvm.smax.i32(i32 %0, i32 0)175 ret i32 %2176}177 178; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn179define i64 @func_smax_back_zero_i64(i64 noundef %0) {180; CHECK-LABEL: func_smax_back_zero_i64:181; CHECK: # %bb.0:182; CHECK-NEXT: maxs.l %s0, 0, %s0183; CHECK-NEXT: b.l.t (, %s10)184 %2 = tail call i64 @llvm.smax.i64(i64 %0, i64 0)185 ret i64 %2186}187 188; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn189define i128 @func_smax_back_zero_i128(i128 noundef %0) {190; CHECK-LABEL: func_smax_back_zero_i128:191; CHECK: # %bb.0:192; CHECK-NEXT: cmov.l.lt %s0, (0)1, %s1193; CHECK-NEXT: maxs.l %s1, 0, %s1194; CHECK-NEXT: b.l.t (, %s10)195 %2 = tail call i128 @llvm.smax.i128(i128 %0, i128 0)196 ret i128 %2197}198 199; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn200define signext i8 @func_smax_fore_const_i8(i8 noundef signext %0) {201; CHECK-LABEL: func_smax_fore_const_i8:202; CHECK: # %bb.0:203; CHECK-NEXT: maxs.w.sx %s0, -1, %s0204; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1205; CHECK-NEXT: b.l.t (, %s10)206 %2 = tail call i8 @llvm.smax.i8(i8 %0, i8 -1)207 ret i8 %2208}209 210; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn211define signext i16 @func_smax_fore_const_i16(i16 noundef signext %0) {212; CHECK-LABEL: func_smax_fore_const_i16:213; CHECK: # %bb.0:214; CHECK-NEXT: maxs.w.sx %s0, %s0, (56)0215; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1216; CHECK-NEXT: b.l.t (, %s10)217 %2 = tail call i16 @llvm.smax.i16(i16 %0, i16 255)218 ret i16 %2219}220 221; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn222define signext i32 @func_smax_fore_const_i32(i32 noundef signext %0) {223; CHECK-LABEL: func_smax_fore_const_i32:224; CHECK: # %bb.0:225; CHECK-NEXT: maxs.w.sx %s0, %s0, (56)0226; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1227; CHECK-NEXT: b.l.t (, %s10)228 %2 = tail call i32 @llvm.smax.i32(i32 %0, i32 255)229 ret i32 %2230}231 232; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn233define i64 @func_smax_fore_const_i64(i64 noundef %0) {234; CHECK-LABEL: func_smax_fore_const_i64:235; CHECK: # %bb.0:236; CHECK-NEXT: maxs.l %s0, %s0, (56)0237; CHECK-NEXT: b.l.t (, %s10)238 %2 = tail call i64 @llvm.smax.i64(i64 %0, i64 255)239 ret i64 %2240}241 242; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn243define i128 @func_smax_fore_const_i128(i128 noundef %0) {244; CHECK-LABEL: func_smax_fore_const_i128:245; CHECK: # %bb.0:246; CHECK-NEXT: or %s2, 0, (0)1247; CHECK-NEXT: cmps.l %s3, %s1, (0)1248; CHECK-NEXT: or %s4, 0, (0)1249; CHECK-NEXT: cmov.l.gt %s4, (63)0, %s3250; CHECK-NEXT: cmpu.l %s3, %s0, (56)0251; CHECK-NEXT: cmov.l.gt %s2, (63)0, %s3252; CHECK-NEXT: cmov.l.eq %s4, %s2, %s1253; CHECK-NEXT: cmov.w.eq %s0, (56)0, %s4254; CHECK-NEXT: cmov.w.eq %s1, (0)1, %s4255; CHECK-NEXT: b.l.t (, %s10)256 %2 = tail call i128 @llvm.smax.i128(i128 %0, i128 255)257 ret i128 %2258}259 260; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn261define signext i8 @func_smax_back_const_i8(i8 noundef signext %0) {262; CHECK-LABEL: func_smax_back_const_i8:263; CHECK: # %bb.0:264; CHECK-NEXT: maxs.w.sx %s0, -1, %s0265; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1266; CHECK-NEXT: b.l.t (, %s10)267 %2 = tail call i8 @llvm.smax.i8(i8 %0, i8 -1)268 ret i8 %2269}270 271; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn272define signext i16 @func_smax_back_const_i16(i16 noundef signext %0) {273; CHECK-LABEL: func_smax_back_const_i16:274; CHECK: # %bb.0:275; CHECK-NEXT: maxs.w.sx %s0, %s0, (56)0276; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1277; CHECK-NEXT: b.l.t (, %s10)278 %2 = tail call i16 @llvm.smax.i16(i16 %0, i16 255)279 ret i16 %2280}281 282; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn283define signext i32 @func_smax_back_const_i32(i32 noundef signext %0) {284; CHECK-LABEL: func_smax_back_const_i32:285; CHECK: # %bb.0:286; CHECK-NEXT: maxs.w.sx %s0, %s0, (56)0287; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1288; CHECK-NEXT: b.l.t (, %s10)289 %2 = tail call i32 @llvm.smax.i32(i32 %0, i32 255)290 ret i32 %2291}292 293; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn294define i64 @func_smax_back_const_i64(i64 noundef %0) {295; CHECK-LABEL: func_smax_back_const_i64:296; CHECK: # %bb.0:297; CHECK-NEXT: maxs.l %s0, %s0, (56)0298; CHECK-NEXT: b.l.t (, %s10)299 %2 = tail call i64 @llvm.smax.i64(i64 %0, i64 255)300 ret i64 %2301}302 303; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn304define i128 @func_smax_back_const_i128(i128 noundef %0) {305; CHECK-LABEL: func_smax_back_const_i128:306; CHECK: # %bb.0:307; CHECK-NEXT: or %s2, 0, (0)1308; CHECK-NEXT: cmps.l %s3, %s1, (0)1309; CHECK-NEXT: or %s4, 0, (0)1310; CHECK-NEXT: cmov.l.gt %s4, (63)0, %s3311; CHECK-NEXT: cmpu.l %s3, %s0, (56)0312; CHECK-NEXT: cmov.l.gt %s2, (63)0, %s3313; CHECK-NEXT: cmov.l.eq %s4, %s2, %s1314; CHECK-NEXT: cmov.w.eq %s0, (56)0, %s4315; CHECK-NEXT: cmov.w.eq %s1, (0)1, %s4316; CHECK-NEXT: b.l.t (, %s10)317 %2 = tail call i128 @llvm.smax.i128(i128 %0, i128 255)318 ret i128 %2319}320 321; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn322declare i32 @llvm.smax.i32(i32, i32)323 324; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn325declare i8 @llvm.smax.i8(i8, i8)326 327; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn328declare i16 @llvm.smax.i16(i16, i16)329 330; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn331declare i64 @llvm.smax.i64(i64, i64)332 333; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn334declare i128 @llvm.smax.i128(i128, i128)335