brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 59f655b Raw
39 lines · plain
1; RUN: llc < %s -mcpu=atom -mtriple=i686-linux | FileCheck %s2; CHECK: addl3; CHECK-NEXT:leal4; CHECK-NEXT:decl5; CHECK-NEXT:jne6 7; Test for the FixupLEAs pre-emit pass. An LEA should be substituted for the ADD8; that increments the array pointer because it is within 5 instructions of the9; corresponding load. The ADD precedes the load by following the loop back edge.10 11; Original C code12;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, ptr nocapture %array) {21entry:22  %cmp4 = icmp sgt i32 %n, 023  br i1 %cmp4, label %for.body, label %for.end24 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, ptr %array, i32 %i.0629  %0 = load i32, ptr %arrayidx, align 430  %add = add nsw i32 %0, %sum.0531  %inc = add nsw i32 %i.06, 132  %exitcond = icmp eq i32 %inc, %n33  br i1 %exitcond, label %for.end, label %for.body34 35for.end:36  %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ]37  ret i32 %sum.0.lcssa38}39