| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | |
| ; RUN: opt < %s -passes=instcombine -S | FileCheck %s | |
| ; Tests to ensure operand reversals are bubbled to the result when there is no | |
| ; increase in the total number of reversals. Often this resuls in back to back | |
| ; reversals that can be eliminated entirely. This outcome is tested separately. | |
| define <vscale x 4 x i32> @binop_reverse(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { | |
| ; CHECK-LABEL: @binop_reverse( | |
| ; CHECK-NEXT: [[ADD1:%.*]] = add nsw <vscale x 4 x i32> [[A:%.*]], [[B:%.*]] | |
| ; CHECK-NEXT: [[ADD:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[ADD1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[ADD]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %add = add nsw <vscale x 4 x i32> %a.rev, %b.rev | |
| ret <vscale x 4 x i32> %add | |
| } | |
| define <vscale x 4 x i32> @binop_intrinsic_reverse(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { | |
| ; CHECK-LABEL: @binop_intrinsic_reverse( | |
| ; 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:%.*]]) | |
| ; CHECK-NEXT: [[SMAX:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[ADD]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SMAX]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %smax = call <vscale x 4 x i32> @llvm.smax(<vscale x 4 x i32> %a.rev, <vscale x 4 x i32> %b.rev) | |
| ret <vscale x 4 x i32> %smax | |
| } | |
| ; %a.rev has multiple uses | |
| define <vscale x 4 x i32> @binop_reverse_1(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { | |
| ; CHECK-LABEL: @binop_reverse_1( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]]) | |
| ; CHECK-NEXT: [[ADD1:%.*]] = add <vscale x 4 x i32> [[A]], [[B:%.*]] | |
| ; CHECK-NEXT: [[ADD:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[ADD1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[ADD]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %a.rev) | |
| %add = add <vscale x 4 x i32> %a.rev, %b.rev | |
| ret <vscale x 4 x i32> %add | |
| } | |
| ; %a.rev has multiple uses | |
| define <vscale x 4 x i32> @binop_intrinsic_reverse_1(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { | |
| ; CHECK-LABEL: @binop_intrinsic_reverse_1( | |
| ; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]]) | |
| ; CHECK-NEXT: [[TMP1:%.*]] = call <vscale x 4 x i32> @llvm.smax.nxv4i32(<vscale x 4 x i32> [[B]], <vscale x 4 x i32> [[B1:%.*]]) | |
| ; CHECK-NEXT: [[SMAX:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[TMP1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SMAX]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %a.rev) | |
| %smax = call <vscale x 4 x i32> @llvm.smax(<vscale x 4 x i32> %a.rev, <vscale x 4 x i32> %b.rev) | |
| ret <vscale x 4 x i32> %smax | |
| } | |
| ; %b.rev has multiple uses | |
| define <vscale x 4 x i32> @binop_reverse_2(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { | |
| ; CHECK-LABEL: @binop_reverse_2( | |
| ; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]]) | |
| ; CHECK-NEXT: [[ADD1:%.*]] = add <vscale x 4 x i32> [[A:%.*]], [[B]] | |
| ; CHECK-NEXT: [[ADD:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[ADD1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[ADD]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %b.rev) | |
| %add = add <vscale x 4 x i32> %a.rev, %b.rev | |
| ret <vscale x 4 x i32> %add | |
| } | |
| ; %a.rev and %b.rev have multiple uses | |
| define <vscale x 4 x i32> @binop_reverse_3(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { | |
| ; CHECK-LABEL: @binop_reverse_3( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]]) | |
| ; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]]) | |
| ; CHECK-NEXT: [[ADD:%.*]] = add <vscale x 4 x i32> [[A_REV]], [[B_REV]] | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[ADD]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %a.rev) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %b.rev) | |
| %add = add <vscale x 4 x i32> %a.rev, %b.rev | |
| ret <vscale x 4 x i32> %add | |
| } | |
| ; %a.rev and %b.rev have multiple uses | |
| define <vscale x 4 x i32> @binop_intrinsic_reverse_3(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { | |
| ; CHECK-LABEL: @binop_intrinsic_reverse_3( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]]) | |
| ; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]]) | |
| ; 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]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SMAX]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %a.rev) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %b.rev) | |
| %smax = call <vscale x 4 x i32> @llvm.smax(<vscale x 4 x i32> %a.rev, <vscale x 4 x i32> %b.rev) | |
| ret <vscale x 4 x i32> %smax | |
| } | |
| ; %a.rev used as both operands | |
| define <vscale x 4 x i32> @binop_reverse_4(<vscale x 4 x i32> %a) { | |
| ; CHECK-LABEL: @binop_reverse_4( | |
| ; CHECK-NEXT: [[MUL1:%.*]] = mul <vscale x 4 x i32> [[A:%.*]], [[A]] | |
| ; CHECK-NEXT: [[MUL:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[MUL1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[MUL]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %mul = mul <vscale x 4 x i32> %a.rev, %a.rev | |
| ret <vscale x 4 x i32> %mul | |
| } | |
| ; %a.rev used as both operands along with a third use | |
| define <vscale x 4 x i32> @binop_reverse_5(<vscale x 4 x i32> %a) { | |
| ; CHECK-LABEL: @binop_reverse_5( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]]) | |
| ; CHECK-NEXT: [[MUL:%.*]] = mul <vscale x 4 x i32> [[A_REV]], [[A_REV]] | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[MUL]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %a.rev) | |
| %mul = mul <vscale x 4 x i32> %a.rev, %a.rev | |
| ret <vscale x 4 x i32> %mul | |
| } | |
| define <vscale x 4 x i32> @binop_reverse_splat_RHS(<vscale x 4 x i32> %a, i32 %b) { | |
| ; CHECK-LABEL: @binop_reverse_splat_RHS( | |
| ; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0 | |
| ; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: [[DIV1:%.*]] = udiv <vscale x 4 x i32> [[A:%.*]], [[B_SPLAT]] | |
| ; CHECK-NEXT: [[DIV:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[DIV1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[DIV]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.insert = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0 | |
| %b.splat = shufflevector <vscale x 4 x i32> %b.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| %div = udiv <vscale x 4 x i32> %a.rev, %b.splat | |
| ret <vscale x 4 x i32> %div | |
| } | |
| ; %a.rev has multiple uses | |
| define <vscale x 4 x i32> @binop_reverse_splat_RHS_1(<vscale x 4 x i32> %a, i32 %b) { | |
| ; CHECK-LABEL: @binop_reverse_splat_RHS_1( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]]) | |
| ; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0 | |
| ; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]]) | |
| ; CHECK-NEXT: [[DIV:%.*]] = udiv <vscale x 4 x i32> [[A_REV]], [[B_SPLAT]] | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[DIV]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.insert = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0 | |
| %b.splat = shufflevector <vscale x 4 x i32> %b.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| call void @use_nxv4i32(<vscale x 4 x i32> %a.rev) | |
| %div = udiv <vscale x 4 x i32> %a.rev, %b.splat | |
| ret <vscale x 4 x i32> %div | |
| } | |
| define <vscale x 4 x i32> @binop_reverse_splat_LHS(<vscale x 4 x i32> %a, i32 %b) { | |
| ; CHECK-LABEL: @binop_reverse_splat_LHS( | |
| ; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0 | |
| ; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: [[DIV1:%.*]] = udiv <vscale x 4 x i32> [[B_SPLAT]], [[A:%.*]] | |
| ; CHECK-NEXT: [[DIV:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[DIV1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[DIV]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.insert = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0 | |
| %b.splat = shufflevector <vscale x 4 x i32> %b.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| %div = udiv <vscale x 4 x i32> %b.splat, %a.rev | |
| ret <vscale x 4 x i32> %div | |
| } | |
| ; %a.rev has multiple uses | |
| define <vscale x 4 x i32> @binop_reverse_splat_LHS_1(<vscale x 4 x i32> %a, i32 %b) { | |
| ; CHECK-LABEL: @binop_reverse_splat_LHS_1( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]]) | |
| ; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0 | |
| ; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]]) | |
| ; CHECK-NEXT: [[DIV:%.*]] = udiv <vscale x 4 x i32> [[B_SPLAT]], [[A_REV]] | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[DIV]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.insert = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0 | |
| %b.splat = shufflevector <vscale x 4 x i32> %b.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| call void @use_nxv4i32(<vscale x 4 x i32> %a.rev) | |
| %div = udiv <vscale x 4 x i32> %b.splat, %a.rev | |
| ret <vscale x 4 x i32> %div | |
| } | |
| define <vscale x 4 x float> @unop_reverse(<vscale x 4 x float> %a) { | |
| ; CHECK-LABEL: @unop_reverse( | |
| ; CHECK-NEXT: [[NEG:%.*]] = fneg fast <vscale x 4 x float> [[A_REV:%.*]] | |
| ; CHECK-NEXT: [[NEG1:%.*]] = call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> [[NEG]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x float> [[NEG1]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a) | |
| %neg = fneg fast <vscale x 4 x float> %a.rev | |
| ret <vscale x 4 x float> %neg | |
| } | |
| ; %a.rev has multiple uses | |
| define <vscale x 4 x float> @unop_reverse_1(<vscale x 4 x float> %a) { | |
| ; CHECK-LABEL: @unop_reverse_1( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> [[A:%.*]]) | |
| ; CHECK-NEXT: call void @use_nxv4f32(<vscale x 4 x float> [[A_REV]]) | |
| ; CHECK-NEXT: [[NEG:%.*]] = fneg fast <vscale x 4 x float> [[A_REV]] | |
| ; CHECK-NEXT: ret <vscale x 4 x float> [[NEG]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a) | |
| call void @use_nxv4f32(<vscale x 4 x float> %a.rev) | |
| %neg = fneg fast <vscale x 4 x float> %a.rev | |
| ret <vscale x 4 x float> %neg | |
| } | |
| define <vscale x 4 x float> @unop_intrinsic_reverse(<vscale x 4 x float> %a) { | |
| ; CHECK-LABEL: @unop_intrinsic_reverse( | |
| ; CHECK-NEXT: [[NEG:%.*]] = call <vscale x 4 x float> @llvm.fabs.nxv4f32(<vscale x 4 x float> [[A_REV:%.*]]) | |
| ; CHECK-NEXT: [[ABS:%.*]] = call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> [[NEG]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x float> [[ABS]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a) | |
| %abs = call <vscale x 4 x float> @llvm.fabs(<vscale x 4 x float> %a.rev) | |
| ret <vscale x 4 x float> %abs | |
| } | |
| define <vscale x 4 x i1> @icmp_reverse(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { | |
| ; CHECK-LABEL: @icmp_reverse( | |
| ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq <vscale x 4 x i32> [[A:%.*]], [[B:%.*]] | |
| ; CHECK-NEXT: [[CMP:%.*]] = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[CMP1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i1> [[CMP]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %cmp = icmp eq <vscale x 4 x i32> %a.rev, %b.rev | |
| ret <vscale x 4 x i1> %cmp | |
| } | |
| ; %a.rev has multiple uses | |
| define <vscale x 4 x i1> @icmp_reverse_1(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { | |
| ; CHECK-LABEL: @icmp_reverse_1( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]]) | |
| ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq <vscale x 4 x i32> [[A]], [[B:%.*]] | |
| ; CHECK-NEXT: [[CMP:%.*]] = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[CMP1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i1> [[CMP]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %a.rev) | |
| %cmp = icmp eq <vscale x 4 x i32> %a.rev, %b.rev | |
| ret <vscale x 4 x i1> %cmp | |
| } | |
| ; %b.rev has multiple uses | |
| define <vscale x 4 x i1> @icmp_reverse_2(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { | |
| ; CHECK-LABEL: @icmp_reverse_2( | |
| ; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]]) | |
| ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq <vscale x 4 x i32> [[A:%.*]], [[B]] | |
| ; CHECK-NEXT: [[CMP:%.*]] = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[CMP1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i1> [[CMP]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %b.rev) | |
| %cmp = icmp eq <vscale x 4 x i32> %a.rev, %b.rev | |
| ret <vscale x 4 x i1> %cmp | |
| } | |
| ; %a.rev and %b.rev have multiple uses | |
| define <vscale x 4 x i1> @icmp_reverse_3(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { | |
| ; CHECK-LABEL: @icmp_reverse_3( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]]) | |
| ; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]]) | |
| ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <vscale x 4 x i32> [[A_REV]], [[B_REV]] | |
| ; CHECK-NEXT: ret <vscale x 4 x i1> [[CMP]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %a.rev) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %b.rev) | |
| %cmp = icmp eq <vscale x 4 x i32> %a.rev, %b.rev | |
| ret <vscale x 4 x i1> %cmp | |
| } | |
| define <vscale x 4 x i1> @icmp_reverse_splat_RHS(<vscale x 4 x i32> %a, i32 %b) { | |
| ; CHECK-LABEL: @icmp_reverse_splat_RHS( | |
| ; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0 | |
| ; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt <vscale x 4 x i32> [[A:%.*]], [[B_SPLAT]] | |
| ; CHECK-NEXT: [[CMP:%.*]] = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[CMP1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i1> [[CMP]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.insert = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0 | |
| %b.splat = shufflevector <vscale x 4 x i32> %b.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| %cmp = icmp sgt <vscale x 4 x i32> %a.rev, %b.splat | |
| ret <vscale x 4 x i1> %cmp | |
| } | |
| ; %a.rev has multiple uses | |
| define <vscale x 4 x i1> @icmp_reverse_splat_RHS_1(<vscale x 4 x i32> %a, i32 %b) { | |
| ; CHECK-LABEL: @icmp_reverse_splat_RHS_1( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]]) | |
| ; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0 | |
| ; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]]) | |
| ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <vscale x 4 x i32> [[A_REV]], [[B_SPLAT]] | |
| ; CHECK-NEXT: ret <vscale x 4 x i1> [[CMP]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.insert = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0 | |
| %b.splat = shufflevector <vscale x 4 x i32> %b.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| call void @use_nxv4i32(<vscale x 4 x i32> %a.rev) | |
| %cmp = icmp sgt <vscale x 4 x i32> %a.rev, %b.splat | |
| ret <vscale x 4 x i1> %cmp | |
| } | |
| define <vscale x 4 x i1> @icmp_reverse_splat_LHS(<vscale x 4 x i32> %a, i32 %b) { | |
| ; CHECK-LABEL: @icmp_reverse_splat_LHS( | |
| ; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0 | |
| ; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult <vscale x 4 x i32> [[B_SPLAT]], [[A:%.*]] | |
| ; CHECK-NEXT: [[CMP:%.*]] = call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[CMP1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i1> [[CMP]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.insert = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0 | |
| %b.splat = shufflevector <vscale x 4 x i32> %b.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| %cmp = icmp ult <vscale x 4 x i32> %b.splat, %a.rev | |
| ret <vscale x 4 x i1> %cmp | |
| } | |
| ; %a.rev has multiple uses | |
| define <vscale x 4 x i1> @icmp_reverse_splat_LHS_1(<vscale x 4 x i32> %a, i32 %b) { | |
| ; CHECK-LABEL: @icmp_reverse_splat_LHS_1( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]]) | |
| ; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0 | |
| ; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]]) | |
| ; CHECK-NEXT: [[CMP:%.*]] = icmp ult <vscale x 4 x i32> [[B_SPLAT]], [[A_REV]] | |
| ; CHECK-NEXT: ret <vscale x 4 x i1> [[CMP]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a) | |
| %b.insert = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0 | |
| %b.splat = shufflevector <vscale x 4 x i32> %b.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| call void @use_nxv4i32(<vscale x 4 x i32> %a.rev) | |
| %cmp = icmp ult <vscale x 4 x i32> %b.splat, %a.rev | |
| ret <vscale x 4 x i1> %cmp | |
| } | |
| define <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) { | |
| ; CHECK-LABEL: @select_reverse( | |
| ; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A:%.*]], <vscale x 4 x i32> [[B:%.*]], <vscale x 4 x i32> [[C:%.*]] | |
| ; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %c.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %c) | |
| %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.rev | |
| ret <vscale x 4 x i32> %select | |
| } | |
| ; %a.rev has multiple uses | |
| define <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) { | |
| ; CHECK-LABEL: @select_reverse_1( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[A:%.*]]) | |
| ; CHECK-NEXT: call void @use_nxv4i1(<vscale x 4 x i1> [[A_REV]]) | |
| ; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A]], <vscale x 4 x i32> [[B:%.*]], <vscale x 4 x i32> [[C:%.*]] | |
| ; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %c.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %c) | |
| call void @use_nxv4i1(<vscale x 4 x i1> %a.rev) | |
| %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.rev | |
| ret <vscale x 4 x i32> %select | |
| } | |
| ; %b.rev has multiple uses | |
| define <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) { | |
| ; CHECK-LABEL: @select_reverse_2( | |
| ; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]]) | |
| ; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A:%.*]], <vscale x 4 x i32> [[B]], <vscale x 4 x i32> [[C:%.*]] | |
| ; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %c.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %c) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %b.rev) | |
| %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.rev | |
| ret <vscale x 4 x i32> %select | |
| } | |
| ; %c.rev has multiple uses | |
| define <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) { | |
| ; CHECK-LABEL: @select_reverse_3( | |
| ; CHECK-NEXT: [[C_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[C:%.*]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[C_REV]]) | |
| ; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A:%.*]], <vscale x 4 x i32> [[B:%.*]], <vscale x 4 x i32> [[C]] | |
| ; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %c.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %c) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %c.rev) | |
| %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.rev | |
| ret <vscale x 4 x i32> %select | |
| } | |
| ; %a.rev and %b.rev have multiple uses | |
| define <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) { | |
| ; CHECK-LABEL: @select_reverse_4( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[A:%.*]]) | |
| ; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]]) | |
| ; CHECK-NEXT: call void @use_nxv4i1(<vscale x 4 x i1> [[A_REV]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]]) | |
| ; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A]], <vscale x 4 x i32> [[B]], <vscale x 4 x i32> [[C:%.*]] | |
| ; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %c.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %c) | |
| call void @use_nxv4i1(<vscale x 4 x i1> %a.rev) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %b.rev) | |
| %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.rev | |
| ret <vscale x 4 x i32> %select | |
| } | |
| ; %a.rev and %c.rev have multiple uses | |
| define <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) { | |
| ; CHECK-LABEL: @select_reverse_5( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[A:%.*]]) | |
| ; CHECK-NEXT: [[C_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[C:%.*]]) | |
| ; CHECK-NEXT: call void @use_nxv4i1(<vscale x 4 x i1> [[A_REV]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[C_REV]]) | |
| ; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A]], <vscale x 4 x i32> [[B:%.*]], <vscale x 4 x i32> [[C]] | |
| ; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %c.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %c) | |
| call void @use_nxv4i1(<vscale x 4 x i1> %a.rev) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %c.rev) | |
| %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.rev | |
| ret <vscale x 4 x i32> %select | |
| } | |
| ; %b.rev and %c.rev have multiple uses | |
| define <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) { | |
| ; CHECK-LABEL: @select_reverse_6( | |
| ; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]]) | |
| ; CHECK-NEXT: [[C_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[C:%.*]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[C_REV]]) | |
| ; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A:%.*]], <vscale x 4 x i32> [[B]], <vscale x 4 x i32> [[C]] | |
| ; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %c.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %c) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %b.rev) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %c.rev) | |
| %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.rev | |
| ret <vscale x 4 x i32> %select | |
| } | |
| ; %a.rev, %b.rev and %c.rev have multiple uses | |
| define <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) { | |
| ; CHECK-LABEL: @select_reverse_7( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[A:%.*]]) | |
| ; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]]) | |
| ; CHECK-NEXT: [[C_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[C:%.*]]) | |
| ; CHECK-NEXT: call void @use_nxv4i1(<vscale x 4 x i1> [[A_REV]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[C_REV]]) | |
| ; 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]] | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %c.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %c) | |
| call void @use_nxv4i1(<vscale x 4 x i1> %a.rev) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %b.rev) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %c.rev) | |
| %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.rev | |
| ret <vscale x 4 x i32> %select | |
| } | |
| define <vscale x 4 x i32> @select_reverse_splat_false(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, i32 %c) { | |
| ; CHECK-LABEL: @select_reverse_splat_false( | |
| ; CHECK-NEXT: [[C_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[C:%.*]], i64 0 | |
| ; CHECK-NEXT: [[C_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[C_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A:%.*]], <vscale x 4 x i32> [[B:%.*]], <vscale x 4 x i32> [[C_SPLAT]] | |
| ; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %c.insert = insertelement <vscale x 4 x i32> poison, i32 %c, i32 0 | |
| %c.splat = shufflevector <vscale x 4 x i32> %c.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.splat | |
| ret <vscale x 4 x i32> %select | |
| } | |
| ; %a.rev has multiple uses | |
| define <vscale x 4 x i32> @select_reverse_splat_false_1(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, i32 %c) { | |
| ; CHECK-LABEL: @select_reverse_splat_false_1( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[A:%.*]]) | |
| ; CHECK-NEXT: [[C_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[C:%.*]], i64 0 | |
| ; CHECK-NEXT: [[C_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[C_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: call void @use_nxv4i1(<vscale x 4 x i1> [[A_REV]]) | |
| ; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A]], <vscale x 4 x i32> [[B:%.*]], <vscale x 4 x i32> [[C_SPLAT]] | |
| ; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %c.insert = insertelement <vscale x 4 x i32> poison, i32 %c, i32 0 | |
| %c.splat = shufflevector <vscale x 4 x i32> %c.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| call void @use_nxv4i1(<vscale x 4 x i1> %a.rev) | |
| %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.splat | |
| ret <vscale x 4 x i32> %select | |
| } | |
| ; %b.rev has multiple uses | |
| define <vscale x 4 x i32> @select_reverse_splat_false_2(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, i32 %c) { | |
| ; CHECK-LABEL: @select_reverse_splat_false_2( | |
| ; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]]) | |
| ; CHECK-NEXT: [[C_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[C:%.*]], i64 0 | |
| ; CHECK-NEXT: [[C_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[C_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]]) | |
| ; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A:%.*]], <vscale x 4 x i32> [[B]], <vscale x 4 x i32> [[C_SPLAT]] | |
| ; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %c.insert = insertelement <vscale x 4 x i32> poison, i32 %c, i32 0 | |
| %c.splat = shufflevector <vscale x 4 x i32> %c.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| call void @use_nxv4i32(<vscale x 4 x i32> %b.rev) | |
| %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.splat | |
| ret <vscale x 4 x i32> %select | |
| } | |
| ; %a.rev and %b.rev have multiple uses | |
| define <vscale x 4 x i32> @select_reverse_splat_false_3(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, i32 %c) { | |
| ; CHECK-LABEL: @select_reverse_splat_false_3( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[A:%.*]]) | |
| ; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]]) | |
| ; CHECK-NEXT: [[C_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[C:%.*]], i64 0 | |
| ; CHECK-NEXT: [[C_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[C_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: call void @use_nxv4i1(<vscale x 4 x i1> [[A_REV]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]]) | |
| ; 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]] | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %c.insert = insertelement <vscale x 4 x i32> poison, i32 %c, i32 0 | |
| %c.splat = shufflevector <vscale x 4 x i32> %c.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| call void @use_nxv4i1(<vscale x 4 x i1> %a.rev) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %b.rev) | |
| %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %b.rev, <vscale x 4 x i32> %c.splat | |
| ret <vscale x 4 x i32> %select | |
| } | |
| define <vscale x 4 x i32> @select_reverse_splat_true(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, i32 %c) { | |
| ; CHECK-LABEL: @select_reverse_splat_true( | |
| ; CHECK-NEXT: [[C_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[C:%.*]], i64 0 | |
| ; CHECK-NEXT: [[C_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[C_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A:%.*]], <vscale x 4 x i32> [[C_SPLAT]], <vscale x 4 x i32> [[B:%.*]] | |
| ; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %c.insert = insertelement <vscale x 4 x i32> poison, i32 %c, i32 0 | |
| %c.splat = shufflevector <vscale x 4 x i32> %c.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %c.splat, <vscale x 4 x i32> %b.rev | |
| ret <vscale x 4 x i32> %select | |
| } | |
| ; %a.rev has multiple uses | |
| define <vscale x 4 x i32> @select_reverse_splat_true_1(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, i32 %c) { | |
| ; CHECK-LABEL: @select_reverse_splat_true_1( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[A:%.*]]) | |
| ; CHECK-NEXT: [[C_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[C:%.*]], i64 0 | |
| ; CHECK-NEXT: [[C_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[C_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: call void @use_nxv4i1(<vscale x 4 x i1> [[A_REV]]) | |
| ; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A]], <vscale x 4 x i32> [[C_SPLAT]], <vscale x 4 x i32> [[B:%.*]] | |
| ; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %c.insert = insertelement <vscale x 4 x i32> poison, i32 %c, i32 0 | |
| %c.splat = shufflevector <vscale x 4 x i32> %c.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| call void @use_nxv4i1(<vscale x 4 x i1> %a.rev) | |
| %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %c.splat, <vscale x 4 x i32> %b.rev | |
| ret <vscale x 4 x i32> %select | |
| } | |
| ; %b.rev has multiple uses | |
| define <vscale x 4 x i32> @select_reverse_splat_true_2(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, i32 %c) { | |
| ; CHECK-LABEL: @select_reverse_splat_true_2( | |
| ; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]]) | |
| ; CHECK-NEXT: [[C_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[C:%.*]], i64 0 | |
| ; CHECK-NEXT: [[C_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[C_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]]) | |
| ; CHECK-NEXT: [[SELECT1:%.*]] = select <vscale x 4 x i1> [[A:%.*]], <vscale x 4 x i32> [[C_SPLAT]], <vscale x 4 x i32> [[B]] | |
| ; CHECK-NEXT: [[SELECT:%.*]] = call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[SELECT1]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %c.insert = insertelement <vscale x 4 x i32> poison, i32 %c, i32 0 | |
| %c.splat = shufflevector <vscale x 4 x i32> %c.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| call void @use_nxv4i32(<vscale x 4 x i32> %b.rev) | |
| %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %c.splat, <vscale x 4 x i32> %b.rev | |
| ret <vscale x 4 x i32> %select | |
| } | |
| ; %a.rev and %b.rev have multiple uses | |
| define <vscale x 4 x i32> @select_reverse_splat_true_3(<vscale x 4 x i1> %a, <vscale x 4 x i32> %b, i32 %c) { | |
| ; CHECK-LABEL: @select_reverse_splat_true_3( | |
| ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> [[A:%.*]]) | |
| ; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]]) | |
| ; CHECK-NEXT: [[C_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[C:%.*]], i64 0 | |
| ; CHECK-NEXT: [[C_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[C_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: call void @use_nxv4i1(<vscale x 4 x i1> [[A_REV]]) | |
| ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]]) | |
| ; 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]] | |
| ; CHECK-NEXT: ret <vscale x 4 x i32> [[SELECT]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a) | |
| %b.rev = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %b) | |
| %c.insert = insertelement <vscale x 4 x i32> poison, i32 %c, i32 0 | |
| %c.splat = shufflevector <vscale x 4 x i32> %c.insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer | |
| call void @use_nxv4i1(<vscale x 4 x i1> %a.rev) | |
| call void @use_nxv4i32(<vscale x 4 x i32> %b.rev) | |
| %select = select <vscale x 4 x i1> %a.rev, <vscale x 4 x i32> %c.splat, <vscale x 4 x i32> %b.rev | |
| ret <vscale x 4 x i32> %select | |
| } | |
| ; Tests to ensure no reversals exist when all operands are reversed and the | |
| ; result is also reversed. | |
| define <vscale x 4 x float> @reverse_binop_reverse(<vscale x 4 x float> %a, <vscale x 4 x float> %b) { | |
| ; CHECK-LABEL: @reverse_binop_reverse( | |
| ; CHECK-NEXT: [[ADD1:%.*]] = fadd <vscale x 4 x float> [[A:%.*]], [[B:%.*]] | |
| ; CHECK-NEXT: ret <vscale x 4 x float> [[ADD1]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a) | |
| %b.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %b) | |
| %add = fadd <vscale x 4 x float> %a.rev, %b.rev | |
| %add.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %add) | |
| ret <vscale x 4 x float> %add.rev | |
| } | |
| define <vscale x 4 x float> @reverse_binop_intrinsic_reverse(<vscale x 4 x float> %a, <vscale x 4 x float> %b) { | |
| ; CHECK-LABEL: @reverse_binop_intrinsic_reverse( | |
| ; 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:%.*]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x float> [[ADD]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a) | |
| %b.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %b) | |
| %maxnum = call <vscale x 4 x float> @llvm.maxnum.nxv4f32(<vscale x 4 x float> %a.rev, <vscale x 4 x float> %b.rev) | |
| %maxnum.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %maxnum) | |
| ret <vscale x 4 x float> %maxnum.rev | |
| } | |
| define <vscale x 4 x float> @reverse_binop_reverse_splat_RHS(<vscale x 4 x float> %a, float %b) { | |
| ; CHECK-LABEL: @reverse_binop_reverse_splat_RHS( | |
| ; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[B:%.*]], i64 0 | |
| ; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x float> [[B_INSERT]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: [[DIV1:%.*]] = fdiv <vscale x 4 x float> [[A:%.*]], [[B_SPLAT]] | |
| ; CHECK-NEXT: ret <vscale x 4 x float> [[DIV1]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a) | |
| %b.insert = insertelement <vscale x 4 x float> poison, float %b, i32 0 | |
| %b.splat = shufflevector <vscale x 4 x float> %b.insert, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer | |
| %div = fdiv <vscale x 4 x float> %a.rev, %b.splat | |
| %div.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %div) | |
| ret <vscale x 4 x float> %div.rev | |
| } | |
| define <vscale x 4 x float> @reverse_binop_reverse_splat_LHS(<vscale x 4 x float> %a, float %b) { | |
| ; CHECK-LABEL: @reverse_binop_reverse_splat_LHS( | |
| ; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[B:%.*]], i64 0 | |
| ; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x float> [[B_INSERT]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: [[DIV1:%.*]] = fdiv <vscale x 4 x float> [[B_SPLAT]], [[A:%.*]] | |
| ; CHECK-NEXT: ret <vscale x 4 x float> [[DIV1]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a) | |
| %b.insert = insertelement <vscale x 4 x float> poison, float %b, i32 0 | |
| %b.splat = shufflevector <vscale x 4 x float> %b.insert, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer | |
| %div = fdiv <vscale x 4 x float> %b.splat, %a.rev | |
| %div.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %div) | |
| ret <vscale x 4 x float> %div.rev | |
| } | |
| define <vscale x 4 x float> @reverse_binop_reverse_intrinsic_splat_RHS(<vscale x 4 x float> %a, float %b) { | |
| ; CHECK-LABEL: @reverse_binop_reverse_intrinsic_splat_RHS( | |
| ; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[B:%.*]], i64 0 | |
| ; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x float> [[B_INSERT]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer | |
| ; 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]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x float> [[MAXNUM]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a) | |
| %b.insert = insertelement <vscale x 4 x float> poison, float %b, i32 0 | |
| %b.splat = shufflevector <vscale x 4 x float> %b.insert, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer | |
| %maxnum = call <vscale x 4 x float> @llvm.maxnum.nxv4f32(<vscale x 4 x float> %a.rev, <vscale x 4 x float> %b.splat) | |
| %maxnum.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %maxnum) | |
| ret <vscale x 4 x float> %maxnum.rev | |
| } | |
| define <vscale x 4 x float> @reverse_binop_reverse_intrinsic_splat_LHS(<vscale x 4 x float> %a, float %b) { | |
| ; CHECK-LABEL: @reverse_binop_reverse_intrinsic_splat_LHS( | |
| ; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[B:%.*]], i64 0 | |
| ; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x float> [[B_INSERT]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer | |
| ; 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:%.*]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x float> [[MAXNUM]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a) | |
| %b.insert = insertelement <vscale x 4 x float> poison, float %b, i32 0 | |
| %b.splat = shufflevector <vscale x 4 x float> %b.insert, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer | |
| %maxnum = call <vscale x 4 x float> @llvm.maxnum.nxv4f32(<vscale x 4 x float> %b.splat, <vscale x 4 x float> %a.rev) | |
| %maxnum.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %maxnum) | |
| ret <vscale x 4 x float> %maxnum.rev | |
| } | |
| ; Negative test: Make sure that splats with poison aren't considered splats | |
| define <4 x float> @reverse_binop_reverse_intrinsic_splat_with_poison(<4 x float> %a) { | |
| ; CHECK-LABEL: @reverse_binop_reverse_intrinsic_splat_with_poison( | |
| ; 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>) | |
| ; CHECK-NEXT: [[MAXNUM:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0> | |
| ; CHECK-NEXT: [[MAXNUM_REV:%.*]] = tail call <4 x float> @llvm.vector.reverse.v4f32(<4 x float> [[MAXNUM]]) | |
| ; CHECK-NEXT: ret <4 x float> [[MAXNUM_REV]] | |
| ; | |
| %a.rev = tail call <4 x float> @llvm.vector.reverse(<4 x float> %a) | |
| %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) | |
| %maxnum.rev = tail call <4 x float> @llvm.vector.reverse(<4 x float> %maxnum) | |
| ret <4 x float> %maxnum.rev | |
| } | |
| define <4 x float> @reverse_binop_reverse_intrinsic_constant_RHS(<4 x float> %a) { | |
| ; CHECK-LABEL: @reverse_binop_reverse_intrinsic_constant_RHS( | |
| ; 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>) | |
| ; CHECK-NEXT: [[MAXNUM:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0> | |
| ; CHECK-NEXT: [[MAXNUM_REV:%.*]] = tail call <4 x float> @llvm.vector.reverse.v4f32(<4 x float> [[MAXNUM]]) | |
| ; CHECK-NEXT: ret <4 x float> [[MAXNUM_REV]] | |
| ; | |
| %a.rev = tail call <4 x float> @llvm.vector.reverse(<4 x float> %a) | |
| %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) | |
| %maxnum.rev = tail call <4 x float> @llvm.vector.reverse(<4 x float> %maxnum) | |
| ret <4 x float> %maxnum.rev | |
| } | |
| define { <4 x i32>, <4 x i1> } @smul_ov_reverse_ops(<4 x i32> %x, <4 x i32> %y) { | |
| ; CHECK-LABEL: define { <4 x i32>, <4 x i1> } @smul_ov_reverse_ops( | |
| ; CHECK-SAME: <4 x i32> [[X:%.*]], <4 x i32> [[Y:%.*]]) { | |
| ; CHECK-NEXT: [[ENTRY:.*:]] | |
| ; CHECK-NEXT: [[REVX:%.*]] = call <4 x i32> @llvm.vector.reverse.v4i32(<4 x i32> [[X]]) | |
| ; CHECK-NEXT: [[REVY:%.*]] = call <4 x i32> @llvm.vector.reverse.v4i32(<4 x i32> [[Y]]) | |
| ; CHECK-NEXT: [[OV:%.*]] = call { <4 x i32>, <4 x i1> } @llvm.smul.with.overflow.v4i32(<4 x i32> [[REVX]], <4 x i32> [[REVY]]) | |
| ; CHECK-NEXT: ret { <4 x i32>, <4 x i1> } [[OV]] | |
| ; | |
| entry: | |
| %revx = call <4 x i32> @llvm.vector.reverse.v4i32(<4 x i32> %x) | |
| %revy = call <4 x i32> @llvm.vector.reverse.v4i32(<4 x i32> %y) | |
| %ov = call { <4 x i32>, <4 x i1> } @llvm.smul.with.overflow.v4i32(<4 x i32> %revx, <4 x i32> %revy) | |
| ret { <4 x i32>, <4 x i1> } %ov | |
| } | |
| define <vscale x 4 x i1> @reverse_fcmp_reverse(<vscale x 4 x float> %a, <vscale x 4 x float> %b) { | |
| ; CHECK-LABEL: @reverse_fcmp_reverse( | |
| ; CHECK-NEXT: [[CMP1:%.*]] = fcmp fast olt <vscale x 4 x float> [[A:%.*]], [[B:%.*]] | |
| ; CHECK-NEXT: ret <vscale x 4 x i1> [[CMP1]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a) | |
| %b.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %b) | |
| %cmp = fcmp fast olt <vscale x 4 x float> %a.rev, %b.rev | |
| %cmp.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %cmp) | |
| ret <vscale x 4 x i1> %cmp.rev | |
| } | |
| define <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) { | |
| ; CHECK-LABEL: @reverse_select_reverse( | |
| ; CHECK-NEXT: [[SELECT1:%.*]] = select fast <vscale x 4 x i1> [[A:%.*]], <vscale x 4 x float> [[B:%.*]], <vscale x 4 x float> [[C:%.*]] | |
| ; CHECK-NEXT: ret <vscale x 4 x float> [[SELECT1]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1> %a) | |
| %b.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %b) | |
| %c.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %c) | |
| %select = select fast <vscale x 4 x i1> %a.rev, <vscale x 4 x float> %b.rev, <vscale x 4 x float> %c.rev | |
| %select.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %select) | |
| ret <vscale x 4 x float> %select.rev | |
| } | |
| define <vscale x 4 x float> @reverse_unop_reverse(<vscale x 4 x float> %a) { | |
| ; CHECK-LABEL: @reverse_unop_reverse( | |
| ; CHECK-NEXT: [[NEG1:%.*]] = fneg <vscale x 4 x float> [[A:%.*]] | |
| ; CHECK-NEXT: ret <vscale x 4 x float> [[NEG1]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a) | |
| %neg = fneg <vscale x 4 x float> %a.rev | |
| %neg.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %neg) | |
| ret <vscale x 4 x float> %neg.rev | |
| } | |
| define <vscale x 4 x float> @reverse_unop_intrinsic_reverse(<vscale x 4 x float> %a) { | |
| ; CHECK-LABEL: @reverse_unop_intrinsic_reverse( | |
| ; CHECK-NEXT: [[ABS:%.*]] = call <vscale x 4 x float> @llvm.fabs.nxv4f32(<vscale x 4 x float> [[A_REV:%.*]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x float> [[ABS]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a) | |
| %abs = call <vscale x 4 x float> @llvm.fabs(<vscale x 4 x float> %a.rev) | |
| %abs.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %abs) | |
| ret <vscale x 4 x float> %abs.rev | |
| } | |
| define <vscale x 4 x float> @reverse_unop_intrinsic_reverse_scalar_arg(<vscale x 4 x float> %a, i32 %power) { | |
| ; CHECK-LABEL: @reverse_unop_intrinsic_reverse_scalar_arg( | |
| ; CHECK-NEXT: [[TMP1:%.*]] = call <vscale x 4 x float> @llvm.powi.nxv4f32.i32(<vscale x 4 x float> [[A:%.*]], i32 [[POWER:%.*]]) | |
| ; CHECK-NEXT: ret <vscale x 4 x float> [[TMP1]] | |
| ; | |
| %a.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %a) | |
| %powi = call <vscale x 4 x float> @llvm.powi.nxv4f32(<vscale x 4 x float> %a.rev, i32 %power) | |
| %powi.rev = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> %powi) | |
| ret <vscale x 4 x float> %powi.rev | |
| } | |
| declare void @use_nxv4i1(<vscale x 4 x i1>) | |
| declare void @use_nxv4i32(<vscale x 4 x i32>) | |
| declare void @use_nxv4f32(<vscale x 4 x float>) | |
| declare <vscale x 4 x i1> @llvm.vector.reverse.nxv4i1(<vscale x 4 x i1>) | |
| declare <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32>) | |
| declare <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float>) |