853 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S | FileCheck %s3 4; Tests to ensure operand reversals are bubbled to the result when there is no5; increase in the total number of reversals. Often this resuls in back to back6; reversals that can be eliminated entirely. This outcome is tested separately.7 8define <vscale x 4 x i32> @binop_reverse(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {9; CHECK-LABEL: @binop_reverse(10; CHECK-NEXT: [[ADD1:%.*]] = add nsw <vscale x 4 x i32> [[A:%.*]], [[B:%.*]]11; CHECK-NEXT: [[ADD:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[ADD1]])12; CHECK-NEXT: ret <vscale x 4 x i32> [[ADD]]13;14 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)15 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)16 %add = add nsw <vscale x 4 x i32> %a.rev, %b.rev17 ret <vscale x 4 x i32> %add18}19 20define <vscale x 4 x i32> @binop_intrinsic_reverse(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {21; CHECK-LABEL: @binop_intrinsic_reverse(22; CHECK-NEXT: [[ADD:%.*]] = call <vscale x 4 x i32> @llvm.smax.nxv4i32(<vscale x 4 x i32> [[A_REV:%.*]], <vscale x 4 x i32> [[B_REV:%.*]])23; CHECK-NEXT: [[SMAX:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[ADD]])24; CHECK-NEXT: ret <vscale x 4 x i32> [[SMAX]]25;26 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)27 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)28 %smax = call <vscale x 4 x i32> @llvm.smax(<vscale x 4 x i32> %a.rev, <vscale x 4 x i32> %b.rev)29 ret <vscale x 4 x i32> %smax30}31 32; %a.rev has multiple uses33define <vscale x 4 x i32> @binop_reverse_1(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {34; CHECK-LABEL: @binop_reverse_1(35; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]])36; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]])37; CHECK-NEXT: [[ADD1:%.*]] = add <vscale x 4 x i32> [[A]], [[B:%.*]]38; CHECK-NEXT: [[ADD:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[ADD1]])39; CHECK-NEXT: ret <vscale x 4 x i32> [[ADD]]40;41 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)42 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)43 call void @use_nxv4i32(<vscale x 4 x i32> %a.rev)44 %add = add <vscale x 4 x i32> %a.rev, %b.rev45 ret <vscale x 4 x i32> %add46}47 48; %a.rev has multiple uses49define <vscale x 4 x i32> @binop_intrinsic_reverse_1(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {50; CHECK-LABEL: @binop_intrinsic_reverse_1(51; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]])52; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]])53; CHECK-NEXT: [[TMP1:%.*]] = call <vscale x 4 x i32> @llvm.smax.nxv4i32(<vscale x 4 x i32> [[B]], <vscale x 4 x i32> [[B1:%.*]])54; CHECK-NEXT: [[SMAX:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[TMP1]])55; CHECK-NEXT: ret <vscale x 4 x i32> [[SMAX]]56;57 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)58 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)59 call void @use_nxv4i32(<vscale x 4 x i32> %a.rev)60 %smax = call <vscale x 4 x i32> @llvm.smax(<vscale x 4 x i32> %a.rev, <vscale x 4 x i32> %b.rev)61 ret <vscale x 4 x i32> %smax62}63 64; %b.rev has multiple uses65define <vscale x 4 x i32> @binop_reverse_2(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {66; CHECK-LABEL: @binop_reverse_2(67; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]])68; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]])69; CHECK-NEXT: [[ADD1:%.*]] = add <vscale x 4 x i32> [[A:%.*]], [[B]]70; CHECK-NEXT: [[ADD:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[ADD1]])71; CHECK-NEXT: ret <vscale x 4 x i32> [[ADD]]72;73 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)74 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)75 call void @use_nxv4i32(<vscale x 4 x i32> %b.rev)76 %add = add <vscale x 4 x i32> %a.rev, %b.rev77 ret <vscale x 4 x i32> %add78}79 80; %a.rev and %b.rev have multiple uses81define <vscale x 4 x i32> @binop_reverse_3(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {82; CHECK-LABEL: @binop_reverse_3(83; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]])84; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]])85; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]])86; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]])87; CHECK-NEXT: [[ADD:%.*]] = add <vscale x 4 x i32> [[A_REV]], [[B_REV]]88; CHECK-NEXT: ret <vscale x 4 x i32> [[ADD]]89;90 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)91 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)92 call void @use_nxv4i32(<vscale x 4 x i32> %a.rev)93 call void @use_nxv4i32(<vscale x 4 x i32> %b.rev)94 %add = add <vscale x 4 x i32> %a.rev, %b.rev95 ret <vscale x 4 x i32> %add96}97 98; %a.rev and %b.rev have multiple uses99define <vscale x 4 x i32> @binop_intrinsic_reverse_3(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {100; CHECK-LABEL: @binop_intrinsic_reverse_3(101; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]])102; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]])103; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]])104; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]])105; CHECK-NEXT: [[SMAX:%.*]] = call <vscale x 4 x i32> @llvm.smax.nxv4i32(<vscale x 4 x i32> [[A_REV]], <vscale x 4 x i32> [[B_REV]])106; CHECK-NEXT: ret <vscale x 4 x i32> [[SMAX]]107;108 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)109 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)110 call void @use_nxv4i32(<vscale x 4 x i32> %a.rev)111 call void @use_nxv4i32(<vscale x 4 x i32> %b.rev)112 %smax = call <vscale x 4 x i32> @llvm.smax(<vscale x 4 x i32> %a.rev, <vscale x 4 x i32> %b.rev)113 ret <vscale x 4 x i32> %smax114}115 116; %a.rev used as both operands117define <vscale x 4 x i32> @binop_reverse_4(<vscale x 4 x i32> %a) {118; CHECK-LABEL: @binop_reverse_4(119; CHECK-NEXT: [[MUL1:%.*]] = mul <vscale x 4 x i32> [[A:%.*]], [[A]]120; CHECK-NEXT: [[MUL:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[MUL1]])121; CHECK-NEXT: ret <vscale x 4 x i32> [[MUL]]122;123 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)124 %mul = mul <vscale x 4 x i32> %a.rev, %a.rev125 ret <vscale x 4 x i32> %mul126}127 128; %a.rev used as both operands along with a third use129define <vscale x 4 x i32> @binop_reverse_5(<vscale x 4 x i32> %a) {130; CHECK-LABEL: @binop_reverse_5(131; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]])132; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]])133; CHECK-NEXT: [[MUL:%.*]] = mul <vscale x 4 x i32> [[A_REV]], [[A_REV]]134; CHECK-NEXT: ret <vscale x 4 x i32> [[MUL]]135;136 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)137 call void @use_nxv4i32(<vscale x 4 x i32> %a.rev)138 %mul = mul <vscale x 4 x i32> %a.rev, %a.rev139 ret <vscale x 4 x i32> %mul140}141 142define <vscale x 4 x i32> @binop_reverse_splat_RHS(<vscale x 4 x i32> %a, i32 %b) {143; CHECK-LABEL: @binop_reverse_splat_RHS(144; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0145; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer146; CHECK-NEXT: [[DIV1:%.*]] = udiv <vscale x 4 x i32> [[A:%.*]], [[B_SPLAT]]147; CHECK-NEXT: [[DIV:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[DIV1]])148; CHECK-NEXT: ret <vscale x 4 x i32> [[DIV]]149;150 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)151 %b.insert = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0152 %b.splat = shufflevector <vscale x 4 x i32> %b.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer153 %div = udiv <vscale x 4 x i32> %a.rev, %b.splat154 ret <vscale x 4 x i32> %div155}156 157; %a.rev has multiple uses158define <vscale x 4 x i32> @binop_reverse_splat_RHS_1(<vscale x 4 x i32> %a, i32 %b) {159; CHECK-LABEL: @binop_reverse_splat_RHS_1(160; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]])161; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0162; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer163; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]])164; CHECK-NEXT: [[DIV:%.*]] = udiv <vscale x 4 x i32> [[A_REV]], [[B_SPLAT]]165; CHECK-NEXT: ret <vscale x 4 x i32> [[DIV]]166;167 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)168 %b.insert = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0169 %b.splat = shufflevector <vscale x 4 x i32> %b.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer170 call void @use_nxv4i32(<vscale x 4 x i32> %a.rev)171 %div = udiv <vscale x 4 x i32> %a.rev, %b.splat172 ret <vscale x 4 x i32> %div173}174 175define <vscale x 4 x i32> @binop_reverse_splat_LHS(<vscale x 4 x i32> %a, i32 %b) {176; CHECK-LABEL: @binop_reverse_splat_LHS(177; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0178; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer179; CHECK-NEXT: [[DIV1:%.*]] = udiv <vscale x 4 x i32> [[B_SPLAT]], [[A:%.*]]180; CHECK-NEXT: [[DIV:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[DIV1]])181; CHECK-NEXT: ret <vscale x 4 x i32> [[DIV]]182;183 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)184 %b.insert = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0185 %b.splat = shufflevector <vscale x 4 x i32> %b.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer186 %div = udiv <vscale x 4 x i32> %b.splat, %a.rev187 ret <vscale x 4 x i32> %div188}189 190; %a.rev has multiple uses191define <vscale x 4 x i32> @binop_reverse_splat_LHS_1(<vscale x 4 x i32> %a, i32 %b) {192; CHECK-LABEL: @binop_reverse_splat_LHS_1(193; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]])194; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0195; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer196; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]])197; CHECK-NEXT: [[DIV:%.*]] = udiv <vscale x 4 x i32> [[B_SPLAT]], [[A_REV]]198; CHECK-NEXT: ret <vscale x 4 x i32> [[DIV]]199;200 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)201 %b.insert = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0202 %b.splat = shufflevector <vscale x 4 x i32> %b.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer203 call void @use_nxv4i32(<vscale x 4 x i32> %a.rev)204 %div = udiv <vscale x 4 x i32> %b.splat, %a.rev205 ret <vscale x 4 x i32> %div206}207 208define <vscale x 4 x float> @unop_reverse(<vscale x 4 x float> %a) {209; CHECK-LABEL: @unop_reverse(210; CHECK-NEXT: [[NEG:%.*]] = fneg fast <vscale x 4 x float> [[A_REV:%.*]]211; CHECK-NEXT: [[NEG1:%.*]] = call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> [[NEG]])212; CHECK-NEXT: ret <vscale x 4 x float> [[NEG1]]213;214 %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a)215 %neg = fneg fast <vscale x 4 x float> %a.rev216 ret <vscale x 4 x float> %neg217}218 219; %a.rev has multiple uses220define <vscale x 4 x float> @unop_reverse_1(<vscale x 4 x float> %a) {221; CHECK-LABEL: @unop_reverse_1(222; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> [[A:%.*]])223; CHECK-NEXT: call void @use_nxv4f32(<vscale x 4 x float> [[A_REV]])224; CHECK-NEXT: [[NEG:%.*]] = fneg fast <vscale x 4 x float> [[A_REV]]225; CHECK-NEXT: ret <vscale x 4 x float> [[NEG]]226;227 %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a)228 call void @use_nxv4f32(<vscale x 4 x float> %a.rev)229 %neg = fneg fast <vscale x 4 x float> %a.rev230 ret <vscale x 4 x float> %neg231}232 233define <vscale x 4 x float> @unop_intrinsic_reverse(<vscale x 4 x float> %a) {234; CHECK-LABEL: @unop_intrinsic_reverse(235; CHECK-NEXT: [[NEG:%.*]] = call <vscale x 4 x float> @llvm.fabs.nxv4f32(<vscale x 4 x float> [[A_REV:%.*]])236; CHECK-NEXT: [[ABS:%.*]] = call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> [[NEG]])237; CHECK-NEXT: ret <vscale x 4 x float> [[ABS]]238;239 %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a)240 %abs = call <vscale x 4 x float> @llvm.fabs(<vscale x 4 x float> %a.rev)241 ret <vscale x 4 x float> %abs242}243 244define <vscale x 4 x i1> @icmp_reverse(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {245; CHECK-LABEL: @icmp_reverse(246; CHECK-NEXT: [[CMP1:%.*]] = icmp eq <vscale x 4 x i32> [[A:%.*]], [[B:%.*]]247; CHECK-NEXT: [[CMP:%.*]] = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[CMP1]])248; CHECK-NEXT: ret <vscale x 4 x i1> [[CMP]]249;250 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)251 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)252 %cmp = icmp eq <vscale x 4 x i32> %a.rev, %b.rev253 ret <vscale x 4 x i1> %cmp254}255 256; %a.rev has multiple uses257define <vscale x 4 x i1> @icmp_reverse_1(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {258; CHECK-LABEL: @icmp_reverse_1(259; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]])260; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]])261; CHECK-NEXT: [[CMP1:%.*]] = icmp eq <vscale x 4 x i32> [[A]], [[B:%.*]]262; CHECK-NEXT: [[CMP:%.*]] = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[CMP1]])263; CHECK-NEXT: ret <vscale x 4 x i1> [[CMP]]264;265 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)266 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)267 call void @use_nxv4i32(<vscale x 4 x i32> %a.rev)268 %cmp = icmp eq <vscale x 4 x i32> %a.rev, %b.rev269 ret <vscale x 4 x i1> %cmp270}271 272; %b.rev has multiple uses273define <vscale x 4 x i1> @icmp_reverse_2(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {274; CHECK-LABEL: @icmp_reverse_2(275; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]])276; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]])277; CHECK-NEXT: [[CMP1:%.*]] = icmp eq <vscale x 4 x i32> [[A:%.*]], [[B]]278; CHECK-NEXT: [[CMP:%.*]] = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[CMP1]])279; CHECK-NEXT: ret <vscale x 4 x i1> [[CMP]]280;281 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)282 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)283 call void @use_nxv4i32(<vscale x 4 x i32> %b.rev)284 %cmp = icmp eq <vscale x 4 x i32> %a.rev, %b.rev285 ret <vscale x 4 x i1> %cmp286}287 288; %a.rev and %b.rev have multiple uses289define <vscale x 4 x i1> @icmp_reverse_3(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {290; CHECK-LABEL: @icmp_reverse_3(291; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]])292; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]])293; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]])294; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]])295; CHECK-NEXT: [[CMP:%.*]] = icmp eq <vscale x 4 x i32> [[A_REV]], [[B_REV]]296; CHECK-NEXT: ret <vscale x 4 x i1> [[CMP]]297;298 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)299 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)300 call void @use_nxv4i32(<vscale x 4 x i32> %a.rev)301 call void @use_nxv4i32(<vscale x 4 x i32> %b.rev)302 %cmp = icmp eq <vscale x 4 x i32> %a.rev, %b.rev303 ret <vscale x 4 x i1> %cmp304}305 306define <vscale x 4 x i1> @icmp_reverse_splat_RHS(<vscale x 4 x i32> %a, i32 %b) {307; CHECK-LABEL: @icmp_reverse_splat_RHS(308; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0309; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer310; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt <vscale x 4 x i32> [[A:%.*]], [[B_SPLAT]]311; CHECK-NEXT: [[CMP:%.*]] = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[CMP1]])312; CHECK-NEXT: ret <vscale x 4 x i1> [[CMP]]313;314 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)315 %b.insert = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0316 %b.splat = shufflevector <vscale x 4 x i32> %b.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer317 %cmp = icmp sgt <vscale x 4 x i32> %a.rev, %b.splat318 ret <vscale x 4 x i1> %cmp319}320 321; %a.rev has multiple uses322define <vscale x 4 x i1> @icmp_reverse_splat_RHS_1(<vscale x 4 x i32> %a, i32 %b) {323; CHECK-LABEL: @icmp_reverse_splat_RHS_1(324; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]])325; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0326; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer327; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]])328; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <vscale x 4 x i32> [[A_REV]], [[B_SPLAT]]329; CHECK-NEXT: ret <vscale x 4 x i1> [[CMP]]330;331 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)332 %b.insert = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0333 %b.splat = shufflevector <vscale x 4 x i32> %b.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer334 call void @use_nxv4i32(<vscale x 4 x i32> %a.rev)335 %cmp = icmp sgt <vscale x 4 x i32> %a.rev, %b.splat336 ret <vscale x 4 x i1> %cmp337}338 339define <vscale x 4 x i1> @icmp_reverse_splat_LHS(<vscale x 4 x i32> %a, i32 %b) {340; CHECK-LABEL: @icmp_reverse_splat_LHS(341; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0342; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer343; CHECK-NEXT: [[CMP1:%.*]] = icmp ult <vscale x 4 x i32> [[B_SPLAT]], [[A:%.*]]344; CHECK-NEXT: [[CMP:%.*]] = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[CMP1]])345; CHECK-NEXT: ret <vscale x 4 x i1> [[CMP]]346;347 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)348 %b.insert = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0349 %b.splat = shufflevector <vscale x 4 x i32> %b.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer350 %cmp = icmp ult <vscale x 4 x i32> %b.splat, %a.rev351 ret <vscale x 4 x i1> %cmp352}353 354; %a.rev has multiple uses355define <vscale x 4 x i1> @icmp_reverse_splat_LHS_1(<vscale x 4 x i32> %a, i32 %b) {356; CHECK-LABEL: @icmp_reverse_splat_LHS_1(357; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]])358; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0359; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer360; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]])361; CHECK-NEXT: [[CMP:%.*]] = icmp ult <vscale x 4 x i32> [[B_SPLAT]], [[A_REV]]362; CHECK-NEXT: ret <vscale x 4 x i1> [[CMP]]363;364 %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)365 %b.insert = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0366 %b.splat = shufflevector <vscale x 4 x i32> %b.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer367 call void @use_nxv4i32(<vscale x 4 x i32> %a.rev)368 %cmp = icmp ult <vscale x 4 x i32> %b.splat, %a.rev369 ret <vscale x 4 x i1> %cmp370}371 372define <vscale x 4 x i32> @select_reverse(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, <vscale x 4 x i32> %c) {373; CHECK-LABEL: @select_reverse(374; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A:%.*]], <vscale x 4 x i32> [[B:%.*]], <vscale x 4 x i32> [[C:%.*]]375; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]])376; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]]377;378 %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a)379 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)380 %c.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %c)381 %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.rev382 ret <vscale x 4 x i32> %select383}384 385; %a.rev has multiple uses386define <vscale x 4 x i32> @select_reverse_1(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, <vscale x 4 x i32> %c) {387; CHECK-LABEL: @select_reverse_1(388; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[A:%.*]])389; CHECK-NEXT: call void @use_nxv4i1(<vscale x 4 x i1> [[A_REV]])390; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A]], <vscale x 4 x i32> [[B:%.*]], <vscale x 4 x i32> [[C:%.*]]391; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]])392; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]]393;394 %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a)395 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)396 %c.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %c)397 call void @use_nxv4i1(<vscale x 4 x i1> %a.rev)398 %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.rev399 ret <vscale x 4 x i32> %select400}401 402; %b.rev has multiple uses403define <vscale x 4 x i32> @select_reverse_2(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, <vscale x 4 x i32> %c) {404; CHECK-LABEL: @select_reverse_2(405; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]])406; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]])407; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A:%.*]], <vscale x 4 x i32> [[B]], <vscale x 4 x i32> [[C:%.*]]408; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]])409; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]]410;411 %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a)412 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)413 %c.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %c)414 call void @use_nxv4i32(<vscale x 4 x i32> %b.rev)415 %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.rev416 ret <vscale x 4 x i32> %select417}418 419; %c.rev has multiple uses420define <vscale x 4 x i32> @select_reverse_3(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, <vscale x 4 x i32> %c) {421; CHECK-LABEL: @select_reverse_3(422; CHECK-NEXT: [[C_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[C:%.*]])423; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[C_REV]])424; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A:%.*]], <vscale x 4 x i32> [[B:%.*]], <vscale x 4 x i32> [[C]]425; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]])426; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]]427;428 %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a)429 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)430 %c.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %c)431 call void @use_nxv4i32(<vscale x 4 x i32> %c.rev)432 %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.rev433 ret <vscale x 4 x i32> %select434}435 436; %a.rev and %b.rev have multiple uses437define <vscale x 4 x i32> @select_reverse_4(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, <vscale x 4 x i32> %c) {438; CHECK-LABEL: @select_reverse_4(439; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[A:%.*]])440; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]])441; CHECK-NEXT: call void @use_nxv4i1(<vscale x 4 x i1> [[A_REV]])442; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]])443; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A]], <vscale x 4 x i32> [[B]], <vscale x 4 x i32> [[C:%.*]]444; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]])445; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]]446;447 %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a)448 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)449 %c.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %c)450 call void @use_nxv4i1(<vscale x 4 x i1> %a.rev)451 call void @use_nxv4i32(<vscale x 4 x i32> %b.rev)452 %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.rev453 ret <vscale x 4 x i32> %select454}455 456; %a.rev and %c.rev have multiple uses457define <vscale x 4 x i32> @select_reverse_5(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, <vscale x 4 x i32> %c) {458; CHECK-LABEL: @select_reverse_5(459; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[A:%.*]])460; CHECK-NEXT: [[C_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[C:%.*]])461; CHECK-NEXT: call void @use_nxv4i1(<vscale x 4 x i1> [[A_REV]])462; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[C_REV]])463; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A]], <vscale x 4 x i32> [[B:%.*]], <vscale x 4 x i32> [[C]]464; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]])465; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]]466;467 %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a)468 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)469 %c.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %c)470 call void @use_nxv4i1(<vscale x 4 x i1> %a.rev)471 call void @use_nxv4i32(<vscale x 4 x i32> %c.rev)472 %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.rev473 ret <vscale x 4 x i32> %select474}475 476; %b.rev and %c.rev have multiple uses477define <vscale x 4 x i32> @select_reverse_6(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, <vscale x 4 x i32> %c) {478; CHECK-LABEL: @select_reverse_6(479; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]])480; CHECK-NEXT: [[C_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[C:%.*]])481; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]])482; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[C_REV]])483; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A:%.*]], <vscale x 4 x i32> [[B]], <vscale x 4 x i32> [[C]]484; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]])485; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]]486;487 %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a)488 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)489 %c.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %c)490 call void @use_nxv4i32(<vscale x 4 x i32> %b.rev)491 call void @use_nxv4i32(<vscale x 4 x i32> %c.rev)492 %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.rev493 ret <vscale x 4 x i32> %select494}495 496; %a.rev, %b.rev and %c.rev have multiple uses497define <vscale x 4 x i32> @select_reverse_7(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, <vscale x 4 x i32> %c) {498; CHECK-LABEL: @select_reverse_7(499; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[A:%.*]])500; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]])501; CHECK-NEXT: [[C_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[C:%.*]])502; CHECK-NEXT: call void @use_nxv4i1(<vscale x 4 x i1> [[A_REV]])503; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]])504; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[C_REV]])505; CHECK-NEXT: [[SELECT:%.*]] = select <vscale x 4 x i1> [[A_REV]], <vscale x 4 x i32> [[B_REV]], <vscale x 4 x i32> [[C_REV]]506; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]]507;508 %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a)509 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)510 %c.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %c)511 call void @use_nxv4i1(<vscale x 4 x i1> %a.rev)512 call void @use_nxv4i32(<vscale x 4 x i32> %b.rev)513 call void @use_nxv4i32(<vscale x 4 x i32> %c.rev)514 %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.rev515 ret <vscale x 4 x i32> %select516}517 518define <vscale x 4 x i32> @select_reverse_splat_false(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, i32 %c) {519; CHECK-LABEL: @select_reverse_splat_false(520; CHECK-NEXT: [[C_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[C:%.*]], i64 0521; CHECK-NEXT: [[C_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[C_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer522; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A:%.*]], <vscale x 4 x i32> [[B:%.*]], <vscale x 4 x i32> [[C_SPLAT]]523; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]])524; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]]525;526 %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a)527 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)528 %c.insert = insertelement <vscale x 4 x i32> poison, i32 %c, i32 0529 %c.splat = shufflevector <vscale x 4 x i32> %c.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer530 %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.splat531 ret <vscale x 4 x i32> %select532}533 534; %a.rev has multiple uses535define <vscale x 4 x i32> @select_reverse_splat_false_1(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, i32 %c) {536; CHECK-LABEL: @select_reverse_splat_false_1(537; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[A:%.*]])538; CHECK-NEXT: [[C_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[C:%.*]], i64 0539; CHECK-NEXT: [[C_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[C_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer540; CHECK-NEXT: call void @use_nxv4i1(<vscale x 4 x i1> [[A_REV]])541; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A]], <vscale x 4 x i32> [[B:%.*]], <vscale x 4 x i32> [[C_SPLAT]]542; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]])543; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]]544;545 %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a)546 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)547 %c.insert = insertelement <vscale x 4 x i32> poison, i32 %c, i32 0548 %c.splat = shufflevector <vscale x 4 x i32> %c.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer549 call void @use_nxv4i1(<vscale x 4 x i1> %a.rev)550 %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.splat551 ret <vscale x 4 x i32> %select552}553 554; %b.rev has multiple uses555define <vscale x 4 x i32> @select_reverse_splat_false_2(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, i32 %c) {556; CHECK-LABEL: @select_reverse_splat_false_2(557; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]])558; CHECK-NEXT: [[C_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[C:%.*]], i64 0559; CHECK-NEXT: [[C_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[C_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer560; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]])561; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A:%.*]], <vscale x 4 x i32> [[B]], <vscale x 4 x i32> [[C_SPLAT]]562; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]])563; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]]564;565 %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a)566 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)567 %c.insert = insertelement <vscale x 4 x i32> poison, i32 %c, i32 0568 %c.splat = shufflevector <vscale x 4 x i32> %c.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer569 call void @use_nxv4i32(<vscale x 4 x i32> %b.rev)570 %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.splat571 ret <vscale x 4 x i32> %select572}573 574; %a.rev and %b.rev have multiple uses575define <vscale x 4 x i32> @select_reverse_splat_false_3(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, i32 %c) {576; CHECK-LABEL: @select_reverse_splat_false_3(577; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[A:%.*]])578; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]])579; CHECK-NEXT: [[C_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[C:%.*]], i64 0580; CHECK-NEXT: [[C_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[C_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer581; CHECK-NEXT: call void @use_nxv4i1(<vscale x 4 x i1> [[A_REV]])582; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]])583; CHECK-NEXT: [[SELECT:%.*]] = select <vscale x 4 x i1> [[A_REV]], <vscale x 4 x i32> [[B_REV]], <vscale x 4 x i32> [[C_SPLAT]]584; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]]585;586 %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a)587 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)588 %c.insert = insertelement <vscale x 4 x i32> poison, i32 %c, i32 0589 %c.splat = shufflevector <vscale x 4 x i32> %c.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer590 call void @use_nxv4i1(<vscale x 4 x i1> %a.rev)591 call void @use_nxv4i32(<vscale x 4 x i32> %b.rev)592 %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.splat593 ret <vscale x 4 x i32> %select594}595 596define <vscale x 4 x i32> @select_reverse_splat_true(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, i32 %c) {597; CHECK-LABEL: @select_reverse_splat_true(598; CHECK-NEXT: [[C_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[C:%.*]], i64 0599; CHECK-NEXT: [[C_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[C_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer600; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A:%.*]], <vscale x 4 x i32> [[C_SPLAT]], <vscale x 4 x i32> [[B:%.*]]601; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]])602; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]]603;604 %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a)605 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)606 %c.insert = insertelement <vscale x 4 x i32> poison, i32 %c, i32 0607 %c.splat = shufflevector <vscale x 4 x i32> %c.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer608 %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %c.splat, <vscale x 4 x i32> %b.rev609 ret <vscale x 4 x i32> %select610}611 612; %a.rev has multiple uses613define <vscale x 4 x i32> @select_reverse_splat_true_1(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, i32 %c) {614; CHECK-LABEL: @select_reverse_splat_true_1(615; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[A:%.*]])616; CHECK-NEXT: [[C_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[C:%.*]], i64 0617; CHECK-NEXT: [[C_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[C_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer618; CHECK-NEXT: call void @use_nxv4i1(<vscale x 4 x i1> [[A_REV]])619; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A]], <vscale x 4 x i32> [[C_SPLAT]], <vscale x 4 x i32> [[B:%.*]]620; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]])621; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]]622;623 %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a)624 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)625 %c.insert = insertelement <vscale x 4 x i32> poison, i32 %c, i32 0626 %c.splat = shufflevector <vscale x 4 x i32> %c.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer627 call void @use_nxv4i1(<vscale x 4 x i1> %a.rev)628 %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %c.splat, <vscale x 4 x i32> %b.rev629 ret <vscale x 4 x i32> %select630}631 632; %b.rev has multiple uses633define <vscale x 4 x i32> @select_reverse_splat_true_2(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, i32 %c) {634; CHECK-LABEL: @select_reverse_splat_true_2(635; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]])636; CHECK-NEXT: [[C_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[C:%.*]], i64 0637; CHECK-NEXT: [[C_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[C_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer638; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]])639; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A:%.*]], <vscale x 4 x i32> [[C_SPLAT]], <vscale x 4 x i32> [[B]]640; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]])641; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]]642;643 %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a)644 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)645 %c.insert = insertelement <vscale x 4 x i32> poison, i32 %c, i32 0646 %c.splat = shufflevector <vscale x 4 x i32> %c.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer647 call void @use_nxv4i32(<vscale x 4 x i32> %b.rev)648 %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %c.splat, <vscale x 4 x i32> %b.rev649 ret <vscale x 4 x i32> %select650}651 652; %a.rev and %b.rev have multiple uses653define <vscale x 4 x i32> @select_reverse_splat_true_3(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, i32 %c) {654; CHECK-LABEL: @select_reverse_splat_true_3(655; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[A:%.*]])656; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]])657; CHECK-NEXT: [[C_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[C:%.*]], i64 0658; CHECK-NEXT: [[C_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[C_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer659; CHECK-NEXT: call void @use_nxv4i1(<vscale x 4 x i1> [[A_REV]])660; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]])661; CHECK-NEXT: [[SELECT:%.*]] = select <vscale x 4 x i1> [[A_REV]], <vscale x 4 x i32> [[C_SPLAT]], <vscale x 4 x i32> [[B_REV]]662; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]]663;664 %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a)665 %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b)666 %c.insert = insertelement <vscale x 4 x i32> poison, i32 %c, i32 0667 %c.splat = shufflevector <vscale x 4 x i32> %c.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer668 call void @use_nxv4i1(<vscale x 4 x i1> %a.rev)669 call void @use_nxv4i32(<vscale x 4 x i32> %b.rev)670 %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %c.splat, <vscale x 4 x i32> %b.rev671 ret <vscale x 4 x i32> %select672}673 674; Tests to ensure no reversals exist when all operands are reversed and the675; result is also reversed.676 677define <vscale x 4 x float> @reverse_binop_reverse(<vscale x 4 x float> %a, <vscale x 4 x float> %b) {678; CHECK-LABEL: @reverse_binop_reverse(679; CHECK-NEXT: [[ADD1:%.*]] = fadd <vscale x 4 x float> [[A:%.*]], [[B:%.*]]680; CHECK-NEXT: ret <vscale x 4 x float> [[ADD1]]681;682 %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a)683 %b.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %b)684 %add = fadd <vscale x 4 x float> %a.rev, %b.rev685 %add.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %add)686 ret <vscale x 4 x float> %add.rev687}688 689define <vscale x 4 x float> @reverse_binop_intrinsic_reverse(<vscale x 4 x float> %a, <vscale x 4 x float> %b) {690; CHECK-LABEL: @reverse_binop_intrinsic_reverse(691; CHECK-NEXT: [[ADD:%.*]] = call <vscale x 4 x float> @llvm.maxnum.nxv4f32(<vscale x 4 x float> [[A_REV:%.*]], <vscale x 4 x float> [[B_REV:%.*]])692; CHECK-NEXT: ret <vscale x 4 x float> [[ADD]]693;694 %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a)695 %b.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %b)696 %maxnum = call <vscale x 4 x float> @llvm.maxnum.nxv4f32(<vscale x 4 x float> %a.rev, <vscale x 4 x float> %b.rev)697 %maxnum.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %maxnum)698 ret <vscale x 4 x float> %maxnum.rev699}700 701define <vscale x 4 x float> @reverse_binop_reverse_splat_RHS(<vscale x 4 x float> %a, float %b) {702; CHECK-LABEL: @reverse_binop_reverse_splat_RHS(703; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[B:%.*]], i64 0704; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x float> [[B_INSERT]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer705; CHECK-NEXT: [[DIV1:%.*]] = fdiv <vscale x 4 x float> [[A:%.*]], [[B_SPLAT]]706; CHECK-NEXT: ret <vscale x 4 x float> [[DIV1]]707;708 %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a)709 %b.insert = insertelement <vscale x 4 x float> poison, float %b, i32 0710 %b.splat = shufflevector <vscale x 4 x float> %b.insert, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer711 %div = fdiv <vscale x 4 x float> %a.rev, %b.splat712 %div.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %div)713 ret <vscale x 4 x float> %div.rev714}715 716define <vscale x 4 x float> @reverse_binop_reverse_splat_LHS(<vscale x 4 x float> %a, float %b) {717; CHECK-LABEL: @reverse_binop_reverse_splat_LHS(718; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[B:%.*]], i64 0719; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x float> [[B_INSERT]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer720; CHECK-NEXT: [[DIV1:%.*]] = fdiv <vscale x 4 x float> [[B_SPLAT]], [[A:%.*]]721; CHECK-NEXT: ret <vscale x 4 x float> [[DIV1]]722;723 %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a)724 %b.insert = insertelement <vscale x 4 x float> poison, float %b, i32 0725 %b.splat = shufflevector <vscale x 4 x float> %b.insert, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer726 %div = fdiv <vscale x 4 x float> %b.splat, %a.rev727 %div.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %div)728 ret <vscale x 4 x float> %div.rev729}730 731define <vscale x 4 x float> @reverse_binop_reverse_intrinsic_splat_RHS(<vscale x 4 x float> %a, float %b) {732; CHECK-LABEL: @reverse_binop_reverse_intrinsic_splat_RHS(733; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[B:%.*]], i64 0734; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x float> [[B_INSERT]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer735; CHECK-NEXT: [[MAXNUM:%.*]] = call <vscale x 4 x float> @llvm.maxnum.nxv4f32(<vscale x 4 x float> [[A_REV:%.*]], <vscale x 4 x float> [[B_SPLAT]])736; CHECK-NEXT: ret <vscale x 4 x float> [[MAXNUM]]737;738 %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a)739 %b.insert = insertelement <vscale x 4 x float> poison, float %b, i32 0740 %b.splat = shufflevector <vscale x 4 x float> %b.insert, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer741 %maxnum = call <vscale x 4 x float> @llvm.maxnum.nxv4f32(<vscale x 4 x float> %a.rev, <vscale x 4 x float> %b.splat)742 %maxnum.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %maxnum)743 ret <vscale x 4 x float> %maxnum.rev744}745 746define <vscale x 4 x float> @reverse_binop_reverse_intrinsic_splat_LHS(<vscale x 4 x float> %a, float %b) {747; CHECK-LABEL: @reverse_binop_reverse_intrinsic_splat_LHS(748; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[B:%.*]], i64 0749; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x float> [[B_INSERT]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer750; CHECK-NEXT: [[MAXNUM:%.*]] = call <vscale x 4 x float> @llvm.maxnum.nxv4f32(<vscale x 4 x float> [[B_SPLAT]], <vscale x 4 x float> [[A_REV:%.*]])751; CHECK-NEXT: ret <vscale x 4 x float> [[MAXNUM]]752;753 %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a)754 %b.insert = insertelement <vscale x 4 x float> poison, float %b, i32 0755 %b.splat = shufflevector <vscale x 4 x float> %b.insert, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer756 %maxnum = call <vscale x 4 x float> @llvm.maxnum.nxv4f32(<vscale x 4 x float> %b.splat, <vscale x 4 x float> %a.rev)757 %maxnum.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %maxnum)758 ret <vscale x 4 x float> %maxnum.rev759}760 761; Negative test: Make sure that splats with poison aren't considered splats762define <4 x float> @reverse_binop_reverse_intrinsic_splat_with_poison(<4 x float> %a) {763; CHECK-LABEL: @reverse_binop_reverse_intrinsic_splat_with_poison(764; CHECK-NEXT: [[TMP1:%.*]] = call <4 x float> @llvm.maxnum.v4f32(<4 x float> [[A:%.*]], <4 x float> <float 1.000000e+00, float poison, float 1.000000e+00, float 1.000000e+00>)765; CHECK-NEXT: [[MAXNUM:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>766; CHECK-NEXT: [[MAXNUM_REV:%.*]] = tail call <4 x float> @llvm.vector.reverse.v4f32(<4 x float> [[MAXNUM]])767; CHECK-NEXT: ret <4 x float> [[MAXNUM_REV]]768;769 %a.rev = tail call <4 x float> @llvm.vector.reverse(<4 x float> %a)770 %maxnum = call <4 x float> @llvm.maxnum.v4f32(<4 x float> <float 1.0, float 1.0, float poison, float 1.0>, <4 x float> %a.rev)771 %maxnum.rev = tail call <4 x float> @llvm.vector.reverse(<4 x float> %maxnum)772 ret <4 x float> %maxnum.rev773}774 775define <4 x float> @reverse_binop_reverse_intrinsic_constant_RHS(<4 x float> %a) {776; CHECK-LABEL: @reverse_binop_reverse_intrinsic_constant_RHS(777; CHECK-NEXT: [[TMP1:%.*]] = call <4 x float> @llvm.maxnum.v4f32(<4 x float> [[A:%.*]], <4 x float> <float 3.000000e+00, float 2.000000e+00, float 1.000000e+00, float 0.000000e+00>)778; CHECK-NEXT: [[MAXNUM:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>779; CHECK-NEXT: [[MAXNUM_REV:%.*]] = tail call <4 x float> @llvm.vector.reverse.v4f32(<4 x float> [[MAXNUM]])780; CHECK-NEXT: ret <4 x float> [[MAXNUM_REV]]781;782 %a.rev = tail call <4 x float> @llvm.vector.reverse(<4 x float> %a)783 %maxnum = call <4 x float> @llvm.maxnum.v4f32(<4 x float> <float 0.0, float 1.0, float 2.0, float 3.0>, <4 x float> %a.rev)784 %maxnum.rev = tail call <4 x float> @llvm.vector.reverse(<4 x float> %maxnum)785 ret <4 x float> %maxnum.rev786}787 788define <vscale x 4 x i1> @reverse_fcmp_reverse(<vscale x 4 x float> %a, <vscale x 4 x float> %b) {789; CHECK-LABEL: @reverse_fcmp_reverse(790; CHECK-NEXT: [[CMP1:%.*]] = fcmp fast olt <vscale x 4 x float> [[A:%.*]], [[B:%.*]]791; CHECK-NEXT: ret <vscale x 4 x i1> [[CMP1]]792;793 %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a)794 %b.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %b)795 %cmp = fcmp fast olt <vscale x 4 x float> %a.rev, %b.rev796 %cmp.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %cmp)797 ret <vscale x 4 x i1> %cmp.rev798}799 800define <vscale x 4 x float> @reverse_select_reverse(<vscale x 4 x i1> %a, <vscale x 4 x float> %b, <vscale x 4 x float> %c) {801; CHECK-LABEL: @reverse_select_reverse(802; CHECK-NEXT: [[SELECT1:%.*]] = select fast <vscale x 4 x i1> [[A:%.*]], <vscale x 4 x float> [[B:%.*]], <vscale x 4 x float> [[C:%.*]]803; CHECK-NEXT: ret <vscale x 4 x float> [[SELECT1]]804;805 %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a)806 %b.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %b)807 %c.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %c)808 %select = select fast <vscale x 4 x i1> %a.rev, <vscale x 4 x float> %b.rev, <vscale x 4 x float> %c.rev809 %select.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %select)810 ret <vscale x 4 x float> %select.rev811}812 813define <vscale x 4 x float> @reverse_unop_reverse(<vscale x 4 x float> %a) {814; CHECK-LABEL: @reverse_unop_reverse(815; CHECK-NEXT: [[NEG1:%.*]] = fneg <vscale x 4 x float> [[A:%.*]]816; CHECK-NEXT: ret <vscale x 4 x float> [[NEG1]]817;818 %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a)819 %neg = fneg <vscale x 4 x float> %a.rev820 %neg.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %neg)821 ret <vscale x 4 x float> %neg.rev822}823 824define <vscale x 4 x float> @reverse_unop_intrinsic_reverse(<vscale x 4 x float> %a) {825; CHECK-LABEL: @reverse_unop_intrinsic_reverse(826; CHECK-NEXT: [[ABS:%.*]] = call <vscale x 4 x float> @llvm.fabs.nxv4f32(<vscale x 4 x float> [[A_REV:%.*]])827; CHECK-NEXT: ret <vscale x 4 x float> [[ABS]]828;829 %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a)830 %abs = call <vscale x 4 x float> @llvm.fabs(<vscale x 4 x float> %a.rev)831 %abs.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %abs)832 ret <vscale x 4 x float> %abs.rev833}834 835define <vscale x 4 x float> @reverse_unop_intrinsic_reverse_scalar_arg(<vscale x 4 x float> %a, i32 %power) {836; CHECK-LABEL: @reverse_unop_intrinsic_reverse_scalar_arg(837; CHECK-NEXT: [[TMP1:%.*]] = call <vscale x 4 x float> @llvm.powi.nxv4f32.i32(<vscale x 4 x float> [[A:%.*]], i32 [[POWER:%.*]])838; CHECK-NEXT: ret <vscale x 4 x float> [[TMP1]]839;840 %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a)841 %powi = call <vscale x 4 x float> @llvm.powi.nxv4f32(<vscale x 4 x float> %a.rev, i32 %power)842 %powi.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %powi)843 ret <vscale x 4 x float> %powi.rev844}845 846declare void @use_nxv4i1(<vscale x 4 x i1>)847declare void @use_nxv4i32(<vscale x 4 x i32>)848declare void @use_nxv4f32(<vscale x 4 x float>)849 850declare <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1>)851declare <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32>)852declare <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float>)853