71 lines · plain
1; RUN: opt -S -passes=gvn-hoist < %s | FileCheck %s2; CHECK-LABEL: build_tree3; CHECK: load4; CHECK: load5; Check that the load is not hoisted because the call can potentially6; modify the global7 8target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"9 10@heap = external global i32, align 411 12define i32 @build_tree() unnamed_addr {13entry:14 br label %do.body15 16do.body: ; preds = %do.body, %entry17 %tmp9 = load i32, ptr @heap, align 418 %cmp = call i1 @pqdownheap(i32 %tmp9)19 br i1 %cmp, label %do.body, label %do.end20 21do.end: ; preds = %do.body22 %tmp20 = load i32, ptr @heap, align 423 ret i32 %tmp2024}25 26declare i1 @pqdownheap(i32)27 28@i = external hidden unnamed_addr global i32, align 429@j = external hidden unnamed_addr global [573 x i32], align 430@v = external global i131 32; CHECK-LABEL: test33; CHECK-LABEL: do.end34; CHECK: load35; Check that the load is not hoisted because the call can potentially36; modify the global37 38define i32 @test() {39entry:40 br label %for.cond41 42for.cond:43 %a3 = load volatile i1, ptr @v44 br i1 %a3, label %for.body, label %while.end45 46for.body:47 br label %if.then48 49if.then:50 %tmp4 = load i32, ptr @i, align 451 br label %for.cond52 53while.end:54 br label %do.body55 56do.body:57 %tmp9 = load i32, ptr getelementptr inbounds ([573 x i32], ptr @j,58i32 0, i32 1), align 459 %tmp10 = load i32, ptr @i, align 460 call void @fn()61 %a1 = load volatile i1, ptr @v62 br i1 %a1, label %do.body, label %do.end63 64do.end:65 %tmp20 = load i32, ptr getelementptr inbounds ([573 x i32], ptr @j,66i32 0, i32 1), align 467 ret i32 %tmp2068}69 70declare void @fn()71