1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -basicaa -slp-vectorizer -dce -S -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s
4 target 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"
5 target triple = "x86_64-apple-macosx10.7.0"
7 @.str = private unnamed_addr constant [6 x i8] c"bingo\00", align 1
9 define void @reduce_compare(double* nocapture %A, i32 %n) {
10 ; CHECK-LABEL: @reduce_compare(
12 ; CHECK-NEXT: [[CONV:%.*]] = sitofp i32 [[N:%.*]] to double
13 ; CHECK-NEXT: [[TMP0:%.*]] = insertelement <2 x double> undef, double [[CONV]], i32 0
14 ; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x double> [[TMP0]], double [[CONV]], i32 1
15 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
17 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_INC:%.*]] ]
18 ; CHECK-NEXT: [[TMP2:%.*]] = shl nsw i64 [[INDVARS_IV]], 1
19 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds double, double* [[A:%.*]], i64 [[TMP2]]
20 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast double* [[ARRAYIDX]] to <2 x double>*
21 ; CHECK-NEXT: [[TMP4:%.*]] = load <2 x double>, <2 x double>* [[TMP3]], align 8
22 ; CHECK-NEXT: [[TMP5:%.*]] = fmul <2 x double> [[TMP1]], [[TMP4]]
23 ; CHECK-NEXT: [[TMP6:%.*]] = fmul <2 x double> [[TMP5]], <double 7.000000e+00, double 4.000000e+00>
24 ; CHECK-NEXT: [[TMP7:%.*]] = fadd <2 x double> [[TMP6]], <double 5.000000e+00, double 9.000000e+00>
25 ; CHECK-NEXT: [[TMP8:%.*]] = extractelement <2 x double> [[TMP7]], i32 0
26 ; CHECK-NEXT: [[TMP9:%.*]] = extractelement <2 x double> [[TMP7]], i32 1
27 ; CHECK-NEXT: [[CMP11:%.*]] = fcmp ogt double [[TMP8]], [[TMP9]]
28 ; CHECK-NEXT: br i1 [[CMP11]], label [[IF_THEN:%.*]], label [[FOR_INC]]
30 ; CHECK-NEXT: [[CALL:%.*]] = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
31 ; CHECK-NEXT: br label [[FOR_INC]]
33 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add i64 [[INDVARS_IV]], 1
34 ; CHECK-NEXT: [[LFTR_WIDEIV:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
35 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i32 [[LFTR_WIDEIV]], 100
36 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
38 ; CHECK-NEXT: ret void
41 %conv = sitofp i32 %n to double
44 for.body: ; preds = %for.inc, %entry
45 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.inc ]
46 %0 = shl nsw i64 %indvars.iv, 1
47 %arrayidx = getelementptr inbounds double, double* %A, i64 %0
48 %1 = load double, double* %arrayidx, align 8
49 %mul1 = fmul double %conv, %1
50 %mul2 = fmul double %mul1, 7.000000e+00
51 %add = fadd double %mul2, 5.000000e+00
53 %arrayidx6 = getelementptr inbounds double, double* %A, i64 %2
54 %3 = load double, double* %arrayidx6, align 8
55 %mul8 = fmul double %conv, %3
56 %mul9 = fmul double %mul8, 4.000000e+00
57 %add10 = fadd double %mul9, 9.000000e+00
58 %cmp11 = fcmp ogt double %add, %add10
59 br i1 %cmp11, label %if.then, label %for.inc
61 if.then: ; preds = %for.body
62 %call = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
65 for.inc: ; preds = %for.body, %if.then
66 %indvars.iv.next = add i64 %indvars.iv, 1
67 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
68 %exitcond = icmp eq i32 %lftr.wideiv, 100
69 br i1 %exitcond, label %for.end, label %for.body
71 for.end: ; preds = %for.inc
75 declare i32 @printf(i8* nocapture, ...)