brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · adea9e1 Raw
85 lines · plain
1; RUN: llc < %s -mcpu=atom -mtriple=i686-linux | FileCheck %s2 3; CHECK:%bb.54; CHECK-NEXT:leal5; CHECK-NEXT:leal6; CHECK-NEXT:leal7; CHECK-NEXT:movl8 9 10; Test for fixup lea pre-emit pass. LEA instructions should be substituted for11; ADD instructions which compute the address and index of the load because they12; precede the load within 5 instructions. An LEA should also be substituted for13; an ADD which computes part of the index because it precedes the index LEA14; within 5 instructions, this substitution is referred to as backwards chaining.15 16; Original C Code17;struct node_t18;{19;  int k, m, n, p;20;  int * array;21;};22 23;extern struct node_t getnode();24 25;int test()26;{27;  int sum = 0;28;  struct node_t n = getnode();29;  if(n.array != 0 && n.p > 0 && n.k > 0 && n.n > 0 && n.m > 0) {30;    sum = ((int*)((int)n.array + n.p) )[ n.k + n.m + n.n ];31;  }32;  return sum;33;}34 35%struct.node_t = type { i32, i32, i32, i32, ptr }36 37define i32 @test() {38entry:39  %n = alloca %struct.node_t, align 440  call void @getnode(ptr sret(%struct.node_t) %n)41  %array = getelementptr inbounds %struct.node_t, ptr %n, i32 0, i32 442  %0 = load ptr, ptr %array, align 443  %cmp = icmp eq ptr %0, null44  br i1 %cmp, label %if.end, label %land.lhs.true45 46land.lhs.true:47  %p = getelementptr inbounds %struct.node_t, ptr %n, i32 0, i32 348  %1 = load i32, ptr %p, align 449  %cmp1 = icmp sgt i32 %1, 050  br i1 %cmp1, label %land.lhs.true2, label %if.end51 52land.lhs.true2:53  %2 = load i32, ptr %n, align 454  %cmp3 = icmp sgt i32 %2, 055  br i1 %cmp3, label %land.lhs.true4, label %if.end56 57land.lhs.true4:58  %n5 = getelementptr inbounds %struct.node_t, ptr %n, i32 0, i32 259  %3 = load i32, ptr %n5, align 460  %cmp6 = icmp sgt i32 %3, 061  br i1 %cmp6, label %land.lhs.true7, label %if.end62 63land.lhs.true7:64  %m = getelementptr inbounds %struct.node_t, ptr %n, i32 0, i32 165  %4 = load i32, ptr %m, align 466  %cmp8 = icmp sgt i32 %4, 067  br i1 %cmp8, label %if.then, label %if.end68 69if.then:70  %add = add i32 %3, %271  %add12 = add i32 %add, %472  %5 = ptrtoint ptr %0 to i3273  %add15 = add nsw i32 %1, %574  %6 = inttoptr i32 %add15 to ptr75  %arrayidx = getelementptr inbounds i32, ptr %6, i32 %add1276  %7 = load i32, ptr %arrayidx, align 477  br label %if.end78 79if.end:80  %sum.0 = phi i32 [ %7, %if.then ], [ 0, %land.lhs.true7 ], [ 0, %land.lhs.true4 ], [ 0, %land.lhs.true2 ], [ 0, %land.lhs.true ], [ 0, %entry ]81  ret i32 %sum.082}83 84declare void @getnode(ptr sret(%struct.node_t), ...)85