46 lines · plain
1; RUN: opt < %s -passes=gvn -S | FileCheck %s2; RUN: opt < %s -passes="gvn<load-pre>" -S | FileCheck %s3 4target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:64:64-v128:128:128-a0:0:32-n32"5 6@p = external global i327 8define i32 @test(i32 %n) nounwind {9; CHECK-LABEL: @test(10entry:11 br label %for.cond12 13; loads aligned greater than the memory should not be moved past conditionals14; CHECK-NOT: load15; CHECK: br i116 17for.cond:18 %i.0 = phi i32 [ 0, %entry ], [ %indvar.next, %for.inc ]19 %cmp = icmp slt i32 %i.0, %n20 br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge21 22for.cond.for.end_crit_edge:23; ...but PRE can still move the load out of for.end to here.24; CHECK: for.cond.for.end_crit_edge:25; CHECK-NEXT: load26 br label %for.end27 28for.body:29 %tmp3 = load i32, ptr @p, align 830 %dec = add i32 %tmp3, -131 store i32 %dec, ptr @p32 %cmp6 = icmp slt i32 %dec, 033 br i1 %cmp6, label %for.body.for.end_crit_edge, label %for.inc34 35for.body.for.end_crit_edge:36 br label %for.end37 38for.inc:39 %indvar.next = add i32 %i.0, 140 br label %for.cond41 42for.end:43 %tmp9 = load i32, ptr @p, align 844 ret i32 %tmp945}46