brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · b82c721 Raw
75 lines · plain
1; RUN: opt < %s -aa-pipeline=basic-aa -passes=gvn -S | FileCheck %s2;3; Check that section->word_ofs doesn't get reloaded in every iteration of the4; for loop.5;6; Code:7;8; typedef struct {9;   unsigned num_words;10;   unsigned word_ofs;11;   const unsigned *data;12; } section_t;13; 14; 15; void test2(const section_t * restrict section, unsigned * restrict dst) {;16;   while (section->data != NULL) {17;     const unsigned *src = section->data;18;     for (unsigned i=0; i < section->num_words; ++i) {19;       dst[section->word_ofs + i] = src[i];20;     }   21; 22;     ++section;23;   }24; }25; 26 27; CHECK-LABEL: for.body:28; CHECK-NOT: load i32, i32* %word_ofs29 30%struct.section_t = type { i32, i32, ptr }31 32define void @test2(ptr noalias nocapture readonly %section, ptr noalias nocapture %dst) {33entry:34  %data13 = getelementptr inbounds %struct.section_t, ptr %section, i32 0, i32 235  %0 = load ptr, ptr %data13, align 436  %cmp14 = icmp eq ptr %0, null37  br i1 %cmp14, label %while.end, label %for.cond.preheader38 39for.cond.preheader:                               ; preds = %entry, %for.end40  %1 = phi ptr [ %6, %for.end ], [ %0, %entry ]41  %section.addr.015 = phi ptr [ %incdec.ptr, %for.end ], [ %section, %entry ]42  %2 = load i32, ptr %section.addr.015, align 443  %cmp211 = icmp eq i32 %2, 044  br i1 %cmp211, label %for.end, label %for.body.lr.ph45 46for.body.lr.ph:                                   ; preds = %for.cond.preheader47  %word_ofs = getelementptr inbounds %struct.section_t, ptr %section.addr.015, i32 0, i32 148  br label %for.body49 50for.body:                                         ; preds = %for.body.lr.ph, %for.body51  %arrayidx.phi = phi ptr [ %1, %for.body.lr.ph ], [ %arrayidx.inc, %for.body ]52  %i.012 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]53  %3 = load i32, ptr %arrayidx.phi, align 454  %4 = load i32, ptr %word_ofs, align 455  %add = add i32 %4, %i.01256  %arrayidx3 = getelementptr inbounds i32, ptr %dst, i32 %add57  store i32 %3, ptr %arrayidx3, align 458  %inc = add i32 %i.012, 159  %5 = load i32, ptr %section.addr.015, align 460  %cmp2 = icmp ult i32 %inc, %561  %arrayidx.inc = getelementptr i32, ptr %arrayidx.phi, i32 162  br i1 %cmp2, label %for.body, label %for.end63 64for.end:                                          ; preds = %for.body, %for.cond.preheader65  %incdec.ptr = getelementptr inbounds %struct.section_t, ptr %section.addr.015, i32 166  %data = getelementptr inbounds %struct.section_t, ptr %section.addr.015, i32 1, i32 267  %6 = load ptr, ptr %data, align 468  %cmp = icmp eq ptr %6, null69  br i1 %cmp, label %while.end, label %for.cond.preheader70 71while.end:                                        ; preds = %for.end, %entry72  ret void73}74 75