1; RUN: llc < %s -mcpu=atom -mtriple=i686-linux | FileCheck %s 2; CHECK: addl 3; CHECK-NEXT:leal 4; CHECK-NEXT:decl 5; CHECK-NEXT:jne 6 7; Test for the FixupLEAs pre-emit pass. An LEA should be substituted for the ADD 8; that increments the array pointer because it is within 5 instructions of the 9; corresponding load. The ADD precedes the load by following the loop back edge. 10 11; Original C code 12;int test(int n, int * array) 13;{ 14; int sum = 0; 15; for(int i = 0; i < n; i++) 16; sum += array[i]; 17; return sum; 18;} 19 20define i32 @test(i32 %n, i32* nocapture %array) { 21entry: 22 %cmp4 = icmp sgt i32 %n, 0 23 br i1 %cmp4, label %for.body, label %for.end 24 25for.body: 26 %i.06 = phi i32 [ %inc, %for.body ], [ 0, %entry ] 27 %sum.05 = phi i32 [ %add, %for.body ], [ 0, %entry ] 28 %arrayidx = getelementptr inbounds i32, i32* %array, i32 %i.06 29 %0 = load i32, i32* %arrayidx, align 4 30 %add = add nsw i32 %0, %sum.05 31 %inc = add nsw i32 %i.06, 1 32 %exitcond = icmp eq i32 %inc, %n 33 br i1 %exitcond, label %for.end, label %for.body 34 35for.end: 36 %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ] 37 ret i32 %sum.0.lcssa 38} 39