brintos

brintos / llvm-project-archived public Read only

0
0
Text · 9.4 KiB · 548a63c Raw
207 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=slp-vectorizer,dce -slp-threshold=-999 -S -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s3 4target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"5target triple = "x86_64-apple-macosx10.8.0"6 7declare double @sin(double) nounwind willreturn8declare double @cos(double) nounwind willreturn9declare double @tan(double) nounwind willreturn10declare double @pow(double, double) nounwind willreturn11declare double @exp2(double) nounwind willreturn12declare double @sqrt(double) nounwind willreturn13declare i64 @round(i64) nounwind willreturn14 15 16define void @sin_libm(ptr %a, ptr %b) {17; CHECK-LABEL: @sin_libm(18; CHECK-NEXT:    [[A0:%.*]] = load double, ptr [[A:%.*]], align 819; CHECK-NEXT:    [[IDX1:%.*]] = getelementptr inbounds double, ptr [[A]], i64 120; CHECK-NEXT:    [[A1:%.*]] = load double, ptr [[IDX1]], align 821; CHECK-NEXT:    [[SIN1:%.*]] = tail call double @sin(double [[A0]]) #[[ATTR3:[0-9]+]]22; CHECK-NEXT:    [[SIN2:%.*]] = tail call double @sin(double [[A1]]) #[[ATTR3]]23; CHECK-NEXT:    store double [[SIN1]], ptr [[B:%.*]], align 824; CHECK-NEXT:    [[IDX2:%.*]] = getelementptr inbounds double, ptr [[B]], i64 125; CHECK-NEXT:    store double [[SIN2]], ptr [[IDX2]], align 826; CHECK-NEXT:    ret void27;28  %a0 = load double, ptr %a, align 829  %idx1 = getelementptr inbounds double, ptr %a, i64 130  %a1 = load double, ptr %idx1, align 831  %sin1 = tail call double @sin(double %a0) nounwind readnone32  %sin2 = tail call double @sin(double %a1) nounwind readnone33  store double %sin1, ptr %b, align 834  %idx2 = getelementptr inbounds double, ptr %b, i64 135  store double %sin2, ptr %idx2, align 836  ret void37}38 39define void @cos_libm(ptr %a, ptr %b) {40; CHECK-LABEL: @cos_libm(41; CHECK-NEXT:    [[A0:%.*]] = load double, ptr [[A:%.*]], align 842; CHECK-NEXT:    [[IDX1:%.*]] = getelementptr inbounds double, ptr [[A]], i64 143; CHECK-NEXT:    [[A1:%.*]] = load double, ptr [[IDX1]], align 844; CHECK-NEXT:    [[COS1:%.*]] = tail call double @cos(double [[A0]]) #[[ATTR3]]45; CHECK-NEXT:    [[COS2:%.*]] = tail call double @cos(double [[A1]]) #[[ATTR3]]46; CHECK-NEXT:    store double [[COS1]], ptr [[B:%.*]], align 847; CHECK-NEXT:    [[IDX2:%.*]] = getelementptr inbounds double, ptr [[B]], i64 148; CHECK-NEXT:    store double [[COS2]], ptr [[IDX2]], align 849; CHECK-NEXT:    ret void50;51  %a0 = load double, ptr %a, align 852  %idx1 = getelementptr inbounds double, ptr %a, i64 153  %a1 = load double, ptr %idx1, align 854  %cos1 = tail call double @cos(double %a0) nounwind readnone55  %cos2 = tail call double @cos(double %a1) nounwind readnone56  store double %cos1, ptr %b, align 857  %idx2 = getelementptr inbounds double, ptr %b, i64 158  store double %cos2, ptr %idx2, align 859  ret void60}61 62define void @tan_libm(ptr %a, ptr %b) {63; CHECK-LABEL: @tan_libm(64; CHECK-NEXT:    [[A0:%.*]] = load double, ptr [[A:%.*]], align 865; CHECK-NEXT:    [[IDX1:%.*]] = getelementptr inbounds double, ptr [[A]], i64 166; CHECK-NEXT:    [[A1:%.*]] = load double, ptr [[IDX1]], align 867; CHECK-NEXT:    [[TAN1:%.*]] = tail call double @tan(double [[A0]]) #[[ATTR3]]68; CHECK-NEXT:    [[TAN2:%.*]] = tail call double @tan(double [[A1]]) #[[ATTR3]]69; CHECK-NEXT:    store double [[TAN1]], ptr [[B:%.*]], align 870; CHECK-NEXT:    [[IDX2:%.*]] = getelementptr inbounds double, ptr [[B]], i64 171; CHECK-NEXT:    store double [[TAN2]], ptr [[IDX2]], align 872; CHECK-NEXT:    ret void73;74  %a0 = load double, ptr %a, align 875  %idx1 = getelementptr inbounds double, ptr %a, i64 176  %a1 = load double, ptr %idx1, align 877  %tan1 = tail call double @tan(double %a0) nounwind readnone78  %tan2 = tail call double @tan(double %a1) nounwind readnone79  store double %tan1, ptr %b, align 880  %idx2 = getelementptr inbounds double, ptr %b, i64 181  store double %tan2, ptr %idx2, align 882  ret void83}84 85define void @pow_libm(ptr %a, ptr %b) {86; CHECK-LABEL: @pow_libm(87; CHECK-NEXT:    [[A0:%.*]] = load double, ptr [[A:%.*]], align 888; CHECK-NEXT:    [[IDX1:%.*]] = getelementptr inbounds double, ptr [[A]], i64 189; CHECK-NEXT:    [[A1:%.*]] = load double, ptr [[IDX1]], align 890; CHECK-NEXT:    [[POW1:%.*]] = tail call double @pow(double [[A0]], double [[A0]]) #[[ATTR3]]91; CHECK-NEXT:    [[POW2:%.*]] = tail call double @pow(double [[A1]], double [[A1]]) #[[ATTR3]]92; CHECK-NEXT:    store double [[POW1]], ptr [[B:%.*]], align 893; CHECK-NEXT:    [[IDX2:%.*]] = getelementptr inbounds double, ptr [[B]], i64 194; CHECK-NEXT:    store double [[POW2]], ptr [[IDX2]], align 895; CHECK-NEXT:    ret void96;97  %a0 = load double, ptr %a, align 898  %idx1 = getelementptr inbounds double, ptr %a, i64 199  %a1 = load double, ptr %idx1, align 8100  %pow1 = tail call double @pow(double %a0, double %a0) nounwind readnone101  %pow2 = tail call double @pow(double %a1, double %a1) nounwind readnone102  store double %pow1, ptr %b, align 8103  %idx2 = getelementptr inbounds double, ptr %b, i64 1104  store double %pow2, ptr %idx2, align 8105  ret void106}107 108define void @exp_libm(ptr %a, ptr %b) {109; CHECK-LABEL: @exp_libm(110; CHECK-NEXT:    [[A0:%.*]] = load double, ptr [[A:%.*]], align 8111; CHECK-NEXT:    [[IDX1:%.*]] = getelementptr inbounds double, ptr [[A]], i64 1112; CHECK-NEXT:    [[A1:%.*]] = load double, ptr [[IDX1]], align 8113; CHECK-NEXT:    [[EXP1:%.*]] = tail call double @exp2(double [[A0]]) #[[ATTR3]]114; CHECK-NEXT:    [[EXP2:%.*]] = tail call double @exp2(double [[A1]]) #[[ATTR3]]115; CHECK-NEXT:    store double [[EXP1]], ptr [[B:%.*]], align 8116; CHECK-NEXT:    [[IDX2:%.*]] = getelementptr inbounds double, ptr [[B]], i64 1117; CHECK-NEXT:    store double [[EXP2]], ptr [[IDX2]], align 8118; CHECK-NEXT:    ret void119;120  %a0 = load double, ptr %a, align 8121  %idx1 = getelementptr inbounds double, ptr %a, i64 1122  %a1 = load double, ptr %idx1, align 8123  %exp1 = tail call double @exp2(double %a0) nounwind readnone124  %exp2 = tail call double @exp2(double %a1) nounwind readnone125  store double %exp1, ptr %b, align 8126  %idx2 = getelementptr inbounds double, ptr %b, i64 1127  store double %exp2, ptr %idx2, align 8128  ret void129}130 131; No fast-math-flags are required to convert sqrt library calls to an intrinsic.132; We just need to know that errno is not set (readnone).133 134define void @sqrt_libm_no_errno(ptr %a, ptr %b) {135; CHECK-LABEL: @sqrt_libm_no_errno(136; CHECK-NEXT:    [[TMP2:%.*]] = load <2 x double>, ptr [[A:%.*]], align 8137; CHECK-NEXT:    [[TMP3:%.*]] = call <2 x double> @llvm.sqrt.v2f64(<2 x double> [[TMP2]])138; CHECK-NEXT:    store <2 x double> [[TMP3]], ptr [[B:%.*]], align 8139; CHECK-NEXT:    ret void140;141  %a0 = load double, ptr %a, align 8142  %idx1 = getelementptr inbounds double, ptr %a, i64 1143  %a1 = load double, ptr %idx1, align 8144  %sqrt1 = tail call double @sqrt(double %a0) nounwind readnone145  %sqrt2 = tail call double @sqrt(double %a1) nounwind readnone146  store double %sqrt1, ptr %b, align 8147  %idx2 = getelementptr inbounds double, ptr %b, i64 1148  store double %sqrt2, ptr %idx2, align 8149  ret void150}151 152; The sqrt intrinsic does not set errno, but a non-constant sqrt call might, so this can't vectorize.153; The nnan on the call does not matter because there's no guarantee in the C standard that a negative154; input would result in a nan output ("On a domain error, the function returns an155; implementation-defined value.")156 157define void @sqrt_libm_errno(ptr %a, ptr %b) {158; CHECK-LABEL: @sqrt_libm_errno(159; CHECK-NEXT:    [[A0:%.*]] = load double, ptr [[A:%.*]], align 8160; CHECK-NEXT:    [[IDX1:%.*]] = getelementptr inbounds double, ptr [[A]], i64 1161; CHECK-NEXT:    [[A1:%.*]] = load double, ptr [[IDX1]], align 8162; CHECK-NEXT:    [[SQRT1:%.*]] = tail call nnan double @sqrt(double [[A0]]) #[[ATTR4:[0-9]+]]163; CHECK-NEXT:    [[SQRT2:%.*]] = tail call nnan double @sqrt(double [[A1]]) #[[ATTR4]]164; CHECK-NEXT:    store double [[SQRT1]], ptr [[B:%.*]], align 8165; CHECK-NEXT:    [[IDX2:%.*]] = getelementptr inbounds double, ptr [[B]], i64 1166; CHECK-NEXT:    store double [[SQRT2]], ptr [[IDX2]], align 8167; CHECK-NEXT:    ret void168;169  %a0 = load double, ptr %a, align 8170  %idx1 = getelementptr inbounds double, ptr %a, i64 1171  %a1 = load double, ptr %idx1, align 8172  %sqrt1 = tail call nnan double @sqrt(double %a0) nounwind173  %sqrt2 = tail call nnan double @sqrt(double %a1) nounwind174  store double %sqrt1, ptr %b, align 8175  %idx2 = getelementptr inbounds double, ptr %b, i64 1176  store double %sqrt2, ptr %idx2, align 8177  ret void178}179 180; Negative test case181define void @round_custom(ptr %a, ptr %b) {182; CHECK-LABEL: @round_custom(183; CHECK-NEXT:    [[A0:%.*]] = load i64, ptr [[A:%.*]], align 8184; CHECK-NEXT:    [[IDX1:%.*]] = getelementptr inbounds i64, ptr [[A]], i64 1185; CHECK-NEXT:    [[A1:%.*]] = load i64, ptr [[IDX1]], align 8186; CHECK-NEXT:    [[ROUND1:%.*]] = tail call i64 @round(i64 [[A0]]) #[[ATTR3]]187; CHECK-NEXT:    [[ROUND2:%.*]] = tail call i64 @round(i64 [[A1]]) #[[ATTR3]]188; CHECK-NEXT:    store i64 [[ROUND1]], ptr [[B:%.*]], align 8189; CHECK-NEXT:    [[IDX2:%.*]] = getelementptr inbounds i64, ptr [[B]], i64 1190; CHECK-NEXT:    store i64 [[ROUND2]], ptr [[IDX2]], align 8191; CHECK-NEXT:    ret void192;193  %a0 = load i64, ptr %a, align 8194  %idx1 = getelementptr inbounds i64, ptr %a, i64 1195  %a1 = load i64, ptr %idx1, align 8196  %round1 = tail call i64 @round(i64 %a0) nounwind readnone197  %round2 = tail call i64 @round(i64 %a1) nounwind readnone198  store i64 %round1, ptr %b, align 8199  %idx2 = getelementptr inbounds i64, ptr %b, i64 1200  store i64 %round2, ptr %idx2, align 8201  ret void202}203 204 205 206 207