1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=armv7-apple-ios -mcpu=cortex-a9 -stress-ivchain | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker; REQUIRES: asserts 3*9880d681SAndroid Build Coastguard Worker 4*9880d681SAndroid Build Coastguard Worker; @sharedidx is an unrolled variant of this loop: 5*9880d681SAndroid Build Coastguard Worker; for (unsigned long i = 0; i < len; i += s) { 6*9880d681SAndroid Build Coastguard Worker; c[i] = a[i] + b[i]; 7*9880d681SAndroid Build Coastguard Worker; } 8*9880d681SAndroid Build Coastguard Worker; where 's' cannot be folded into the addressing mode. 9*9880d681SAndroid Build Coastguard Worker; 10*9880d681SAndroid Build Coastguard Worker; This is not quite profitable to chain. But with -stress-ivchain, we 11*9880d681SAndroid Build Coastguard Worker; can form three address chains in place of the shared induction 12*9880d681SAndroid Build Coastguard Worker; variable. 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Worker; rdar://10674430 15*9880d681SAndroid Build Coastguard Workerdefine void @sharedidx(i8* nocapture %a, i8* nocapture %b, i8* nocapture %c, i32 %s, i32 %len) nounwind ssp { 16*9880d681SAndroid Build Coastguard Workerentry: 17*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sharedidx: 18*9880d681SAndroid Build Coastguard Worker %cmp8 = icmp eq i32 %len, 0 19*9880d681SAndroid Build Coastguard Worker br i1 %cmp8, label %for.end, label %for.body 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Workerfor.body: ; preds = %entry, %for.body.3 22*9880d681SAndroid Build Coastguard Worker; CHECK: %for.body 23*9880d681SAndroid Build Coastguard Worker; CHECK: ldrb {{r[0-9]+|lr}}, [{{r[0-9]+|lr}}, {{r[0-9]+|lr}}]! 24*9880d681SAndroid Build Coastguard Worker; CHECK: ldrb {{r[0-9]+|lr}}, [{{r[0-9]+|lr}}, {{r[0-9]+|lr}}]! 25*9880d681SAndroid Build Coastguard Worker %i.09 = phi i32 [ %add5.3, %for.body.3 ], [ 0, %entry ] 26*9880d681SAndroid Build Coastguard Worker %arrayidx = getelementptr inbounds i8, i8* %a, i32 %i.09 27*9880d681SAndroid Build Coastguard Worker %0 = load i8, i8* %arrayidx, align 1 28*9880d681SAndroid Build Coastguard Worker %conv6 = zext i8 %0 to i32 29*9880d681SAndroid Build Coastguard Worker %arrayidx1 = getelementptr inbounds i8, i8* %b, i32 %i.09 30*9880d681SAndroid Build Coastguard Worker %1 = load i8, i8* %arrayidx1, align 1 31*9880d681SAndroid Build Coastguard Worker %conv27 = zext i8 %1 to i32 32*9880d681SAndroid Build Coastguard Worker %add = add nsw i32 %conv27, %conv6 33*9880d681SAndroid Build Coastguard Worker %conv3 = trunc i32 %add to i8 34*9880d681SAndroid Build Coastguard Worker %arrayidx4 = getelementptr inbounds i8, i8* %c, i32 %i.09 35*9880d681SAndroid Build Coastguard Worker store i8 %conv3, i8* %arrayidx4, align 1 36*9880d681SAndroid Build Coastguard Worker %add5 = add i32 %i.09, %s 37*9880d681SAndroid Build Coastguard Worker %cmp = icmp ult i32 %add5, %len 38*9880d681SAndroid Build Coastguard Worker br i1 %cmp, label %for.body.1, label %for.end 39*9880d681SAndroid Build Coastguard Worker 40*9880d681SAndroid Build Coastguard Workerfor.end: ; preds = %for.body, %for.body.1, %for.body.2, %for.body.3, %entry 41*9880d681SAndroid Build Coastguard Worker ret void 42*9880d681SAndroid Build Coastguard Worker 43*9880d681SAndroid Build Coastguard Workerfor.body.1: ; preds = %for.body 44*9880d681SAndroid Build Coastguard Worker; CHECK: %for.body.1 45*9880d681SAndroid Build Coastguard Worker; CHECK: ldrb {{r[0-9]+|lr}}, [{{r[0-9]+|lr}}, {{r[0-9]+|lr}}]! 46*9880d681SAndroid Build Coastguard Worker; CHECK: ldrb {{r[0-9]+|lr}}, [{{r[0-9]+|lr}}, {{r[0-9]+|lr}}]! 47*9880d681SAndroid Build Coastguard Worker %arrayidx.1 = getelementptr inbounds i8, i8* %a, i32 %add5 48*9880d681SAndroid Build Coastguard Worker %2 = load i8, i8* %arrayidx.1, align 1 49*9880d681SAndroid Build Coastguard Worker %conv6.1 = zext i8 %2 to i32 50*9880d681SAndroid Build Coastguard Worker %arrayidx1.1 = getelementptr inbounds i8, i8* %b, i32 %add5 51*9880d681SAndroid Build Coastguard Worker %3 = load i8, i8* %arrayidx1.1, align 1 52*9880d681SAndroid Build Coastguard Worker %conv27.1 = zext i8 %3 to i32 53*9880d681SAndroid Build Coastguard Worker %add.1 = add nsw i32 %conv27.1, %conv6.1 54*9880d681SAndroid Build Coastguard Worker %conv3.1 = trunc i32 %add.1 to i8 55*9880d681SAndroid Build Coastguard Worker %arrayidx4.1 = getelementptr inbounds i8, i8* %c, i32 %add5 56*9880d681SAndroid Build Coastguard Worker store i8 %conv3.1, i8* %arrayidx4.1, align 1 57*9880d681SAndroid Build Coastguard Worker %add5.1 = add i32 %add5, %s 58*9880d681SAndroid Build Coastguard Worker %cmp.1 = icmp ult i32 %add5.1, %len 59*9880d681SAndroid Build Coastguard Worker br i1 %cmp.1, label %for.body.2, label %for.end 60*9880d681SAndroid Build Coastguard Worker 61*9880d681SAndroid Build Coastguard Workerfor.body.2: ; preds = %for.body.1 62*9880d681SAndroid Build Coastguard Worker %arrayidx.2 = getelementptr inbounds i8, i8* %a, i32 %add5.1 63*9880d681SAndroid Build Coastguard Worker %4 = load i8, i8* %arrayidx.2, align 1 64*9880d681SAndroid Build Coastguard Worker %conv6.2 = zext i8 %4 to i32 65*9880d681SAndroid Build Coastguard Worker %arrayidx1.2 = getelementptr inbounds i8, i8* %b, i32 %add5.1 66*9880d681SAndroid Build Coastguard Worker %5 = load i8, i8* %arrayidx1.2, align 1 67*9880d681SAndroid Build Coastguard Worker %conv27.2 = zext i8 %5 to i32 68*9880d681SAndroid Build Coastguard Worker %add.2 = add nsw i32 %conv27.2, %conv6.2 69*9880d681SAndroid Build Coastguard Worker %conv3.2 = trunc i32 %add.2 to i8 70*9880d681SAndroid Build Coastguard Worker %arrayidx4.2 = getelementptr inbounds i8, i8* %c, i32 %add5.1 71*9880d681SAndroid Build Coastguard Worker store i8 %conv3.2, i8* %arrayidx4.2, align 1 72*9880d681SAndroid Build Coastguard Worker %add5.2 = add i32 %add5.1, %s 73*9880d681SAndroid Build Coastguard Worker %cmp.2 = icmp ult i32 %add5.2, %len 74*9880d681SAndroid Build Coastguard Worker br i1 %cmp.2, label %for.body.3, label %for.end 75*9880d681SAndroid Build Coastguard Worker 76*9880d681SAndroid Build Coastguard Workerfor.body.3: ; preds = %for.body.2 77*9880d681SAndroid Build Coastguard Worker; CHECK: %for.body.3 78*9880d681SAndroid Build Coastguard Worker; CHECK: ldrb {{r[0-9]+|lr}}, [{{r[0-9]+|lr}}, {{r[0-9]+|lr}}]! 79*9880d681SAndroid Build Coastguard Worker; CHECK: ldrb {{r[0-9]+|lr}}, [{{r[0-9]+|lr}}, {{r[0-9]+|lr}}]! 80*9880d681SAndroid Build Coastguard Worker %arrayidx.3 = getelementptr inbounds i8, i8* %a, i32 %add5.2 81*9880d681SAndroid Build Coastguard Worker %6 = load i8, i8* %arrayidx.3, align 1 82*9880d681SAndroid Build Coastguard Worker %conv6.3 = zext i8 %6 to i32 83*9880d681SAndroid Build Coastguard Worker %arrayidx1.3 = getelementptr inbounds i8, i8* %b, i32 %add5.2 84*9880d681SAndroid Build Coastguard Worker %7 = load i8, i8* %arrayidx1.3, align 1 85*9880d681SAndroid Build Coastguard Worker %conv27.3 = zext i8 %7 to i32 86*9880d681SAndroid Build Coastguard Worker %add.3 = add nsw i32 %conv27.3, %conv6.3 87*9880d681SAndroid Build Coastguard Worker %conv3.3 = trunc i32 %add.3 to i8 88*9880d681SAndroid Build Coastguard Worker %arrayidx4.3 = getelementptr inbounds i8, i8* %c, i32 %add5.2 89*9880d681SAndroid Build Coastguard Worker store i8 %conv3.3, i8* %arrayidx4.3, align 1 90*9880d681SAndroid Build Coastguard Worker %add5.3 = add i32 %add5.2, %s 91*9880d681SAndroid Build Coastguard Worker %cmp.3 = icmp ult i32 %add5.3, %len 92*9880d681SAndroid Build Coastguard Worker br i1 %cmp.3, label %for.body, label %for.end 93*9880d681SAndroid Build Coastguard Worker} 94