108 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=loop-vectorize,instsimplify -force-vector-interleave=1 -S | FileCheck %s --check-prefixes=WIDE3; RUN: opt < %s -passes=loop-vectorize,instsimplify -force-vector-interleave=1 -vectorizer-maximize-bandwidth-for-vector-calls=false -S | FileCheck %s --check-prefixes=NARROW4 5target triple = "aarch64-unknown-linux-gnu"6 7define void @test_widen(ptr noalias %a, ptr readnone %b) #1 {8; WIDE-LABEL: @test_widen(9; WIDE-NEXT: entry:10; WIDE-NEXT: br label [[VECTOR_PH:%.*]]11; WIDE: vector.ph:12; WIDE-NEXT: [[TMP2:%.*]] = call i64 @llvm.vscale.i64()13; WIDE-NEXT: [[TMP3:%.*]] = mul nuw i64 [[TMP2]], 414; WIDE-NEXT: [[N_MOD_VF:%.*]] = urem i64 1025, [[TMP3]]15; WIDE-NEXT: [[N_VEC:%.*]] = sub i64 1025, [[N_MOD_VF]]16; WIDE-NEXT: br label [[VECTOR_BODY:%.*]]17; WIDE: vector.body:18; WIDE-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]19; WIDE-NEXT: [[TMP4:%.*]] = getelementptr double, ptr [[B:%.*]], i64 [[INDEX]]20; WIDE-NEXT: [[WIDE_LOAD:%.*]] = load <vscale x 4 x double>, ptr [[TMP4]], align 821; WIDE-NEXT: [[TMP5:%.*]] = fptrunc <vscale x 4 x double> [[WIDE_LOAD]] to <vscale x 4 x float>22; WIDE-NEXT: [[TMP6:%.*]] = call <vscale x 4 x float> @foo_vector(<vscale x 4 x float> [[TMP5]], <vscale x 4 x i1> splat (i1 true))23; WIDE-NEXT: [[TMP7:%.*]] = getelementptr inbounds float, ptr [[A:%.*]], i64 [[INDEX]]24; WIDE-NEXT: store <vscale x 4 x float> [[TMP6]], ptr [[TMP7]], align 425; WIDE-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], [[TMP3]]26; WIDE-NEXT: [[TMP10:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]27; WIDE-NEXT: br i1 [[TMP10]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]28; WIDE: middle.block:29; WIDE-NEXT: br i1 false, label [[FOR_COND_CLEANUP:%.*]], label [[SCALAR_PH:%.*]]30; WIDE: scalar.ph:31; WIDE-NEXT: br label [[FOR_BODY:%.*]]32; WIDE: for.body:33; WIDE-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[N_VEC]], [[SCALAR_PH]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]34; WIDE-NEXT: [[GEP:%.*]] = getelementptr double, ptr [[B]], i64 [[INDVARS_IV]]35; WIDE-NEXT: [[LOAD:%.*]] = load double, ptr [[GEP]], align 836; WIDE-NEXT: [[TRUNC:%.*]] = fptrunc double [[LOAD]] to float37; WIDE-NEXT: [[CALL:%.*]] = call float @foo(float [[TRUNC]]) #[[ATTR2:[0-9]+]]38; WIDE-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[INDVARS_IV]]39; WIDE-NEXT: store float [[CALL]], ptr [[ARRAYIDX]], align 440; WIDE-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 141; WIDE-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 102542; WIDE-NEXT: br i1 [[EXITCOND]], label [[FOR_COND_CLEANUP]], label [[FOR_BODY]], !llvm.loop [[LOOP3:![0-9]+]]43; WIDE: for.cond.cleanup:44; WIDE-NEXT: ret void45;46; NARROW-LABEL: @test_widen(47; NARROW-NEXT: entry:48; NARROW-NEXT: br label [[VECTOR_PH:%.*]]49; NARROW: vector.ph:50; NARROW-NEXT: [[TMP2:%.*]] = call i64 @llvm.vscale.i64()51; NARROW-NEXT: [[TMP1:%.*]] = mul nuw i64 [[TMP2]], 452; NARROW-NEXT: [[N_MOD_VF:%.*]] = urem i64 1025, [[TMP1]]53; NARROW-NEXT: [[N_VEC:%.*]] = sub i64 1025, [[N_MOD_VF]]54; NARROW-NEXT: br label [[VECTOR_BODY:%.*]]55; NARROW: vector.body:56; NARROW-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]57; NARROW-NEXT: [[TMP0:%.*]] = getelementptr double, ptr [[B:%.*]], i64 [[INDEX]]58; NARROW-NEXT: [[WIDE_LOAD:%.*]] = load <vscale x 4 x double>, ptr [[TMP0]], align 859; NARROW-NEXT: [[TMP3:%.*]] = fptrunc <vscale x 4 x double> [[WIDE_LOAD]] to <vscale x 4 x float>60; NARROW-NEXT: [[TMP4:%.*]] = call <vscale x 4 x float> @foo_vector(<vscale x 4 x float> [[TMP3]], <vscale x 4 x i1> splat (i1 true))61; NARROW-NEXT: [[TMP8:%.*]] = getelementptr inbounds float, ptr [[A:%.*]], i64 [[INDEX]]62; NARROW-NEXT: store <vscale x 4 x float> [[TMP4]], ptr [[TMP8]], align 463; NARROW-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], [[TMP1]]64; NARROW-NEXT: [[TMP6:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]65; NARROW-NEXT: br i1 [[TMP6]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]66; NARROW: middle.block:67; NARROW-NEXT: br i1 false, label [[FOR_COND_CLEANUP:%.*]], label [[SCALAR_PH:%.*]]68; NARROW: scalar.ph:69; NARROW-NEXT: br label [[FOR_BODY:%.*]]70; NARROW: for.body:71; NARROW-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[N_VEC]], [[SCALAR_PH]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]72; NARROW-NEXT: [[GEP:%.*]] = getelementptr double, ptr [[B]], i64 [[INDVARS_IV]]73; NARROW-NEXT: [[LOAD:%.*]] = load double, ptr [[GEP]], align 874; NARROW-NEXT: [[TRUNC:%.*]] = fptrunc double [[LOAD]] to float75; NARROW-NEXT: [[CALL:%.*]] = call float @foo(float [[TRUNC]]) #[[ATTR2:[0-9]+]]76; NARROW-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[INDVARS_IV]]77; NARROW-NEXT: store float [[CALL]], ptr [[ARRAYIDX]], align 478; NARROW-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 179; NARROW-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 102580; NARROW-NEXT: br i1 [[EXITCOND]], label [[FOR_COND_CLEANUP]], label [[FOR_BODY]], !llvm.loop [[LOOP3:![0-9]+]]81; NARROW: for.cond.cleanup:82; NARROW-NEXT: ret void83;84entry:85 br label %for.body86 87for.body:88 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]89 %gep = getelementptr double, ptr %b, i64 %indvars.iv90 %load = load double, ptr %gep91 %trunc = fptrunc double %load to float92 %call = call float @foo(float %trunc) #093 %arrayidx = getelementptr inbounds float, ptr %a, i64 %indvars.iv94 store float %call, ptr %arrayidx95 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 196 %exitcond = icmp eq i64 %indvars.iv.next, 102597 br i1 %exitcond, label %for.cond.cleanup, label %for.body98 99for.cond.cleanup:100 ret void101}102 103declare float @foo(float)104declare <vscale x 4 x float> @foo_vector(<vscale x 4 x float>, <vscale x 4 x i1>)105 106attributes #0 = { nounwind "vector-function-abi-variant"="_ZGVsMxv_foo(foo_vector)" }107attributes #1 = { "target-features"="+sve" vscale_range(1,16) "no-trapping-math"="false" }108