Home | History | Annotate | Download | only in GVN
      1 ; RUN: opt < %s -gvn -enable-load-pre -S | not grep pre1
      2 ; GVN load pre was hoisting the loads at %13 and %16 up to bb4.outer.  
      3 ; This is invalid as it bypasses the check for %m.0.ph==null in bb4. 
      4 ; ModuleID = 'mbuf.c'
      5 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
      6 target triple = "i386-apple-darwin9.6"
      7   %struct.mbuf = type { %struct.mbuf*, %struct.mbuf*, i32, i8*, i16, i16, i32 }
      8 
      9 define void @m_adj(%struct.mbuf* %mp, i32 %req_len) nounwind optsize {
     10 entry:
     11   %0 = icmp eq %struct.mbuf* %mp, null    ; <i1> [#uses=1]
     12   %1 = icmp slt i32 %req_len, 0   ; <i1> [#uses=1]
     13   %or.cond = or i1 %1, %0   ; <i1> [#uses=1]
     14   br i1 %or.cond, label %return, label %bb4.preheader
     15 
     16 bb4.preheader:    ; preds = %entry
     17   br label %bb4.outer
     18 
     19 bb2:    ; preds = %bb1
     20   %2 = sub i32 %len.0, %13   ; <i32> [#uses=1]
     21   %3 = getelementptr %struct.mbuf* %m.0.ph, i32 0, i32 2    ; <i32*> [#uses=1]
     22   store i32 0, i32* %3, align 4
     23   %4 = getelementptr %struct.mbuf* %m.0.ph, i32 0, i32 0    ; <%struct.mbuf**> [#uses=1]
     24   %5 = load %struct.mbuf** %4, align 4    ; <%struct.mbuf*> [#uses=1]
     25   br label %bb4.outer
     26 
     27 bb4.outer:    ; preds = %bb4.preheader, %bb2
     28   %m.0.ph = phi %struct.mbuf* [ %5, %bb2 ], [ %mp, %bb4.preheader ]   ; <%struct.mbuf*> [#uses=7]
     29   %len.0.ph = phi i32 [ %2, %bb2 ], [ %req_len, %bb4.preheader ]    ; <i32> [#uses=1]
     30   %6 = icmp ne %struct.mbuf* %m.0.ph, null    ; <i1> [#uses=1]
     31   %7 = getelementptr %struct.mbuf* %m.0.ph, i32 0, i32 2    ; <i32*> [#uses=1]
     32   %8 = getelementptr %struct.mbuf* %m.0.ph, i32 0, i32 2   ; <i32*> [#uses=1]
     33   %9 = getelementptr %struct.mbuf* %m.0.ph, i32 0, i32 3   ; <i8**> [#uses=1]
     34   %10 = getelementptr %struct.mbuf* %m.0.ph, i32 0, i32 3   ; <i8**> [#uses=1]
     35   br label %bb4
     36 
     37 bb4:    ; preds = %bb4.outer, %bb3
     38   %len.0 = phi i32 [ 0, %bb3 ], [ %len.0.ph, %bb4.outer ]   ; <i32> [#uses=6]
     39   %11 = icmp sgt i32 %len.0, 0    ; <i1> [#uses=1]
     40   %12 = and i1 %11, %6    ; <i1> [#uses=1]
     41   br i1 %12, label %bb1, label %bb7
     42 
     43 bb1:    ; preds = %bb4
     44   %13 = load i32* %7, align 4    ; <i32> [#uses=3]
     45   %14 = icmp sgt i32 %13, %len.0    ; <i1> [#uses=1]
     46   br i1 %14, label %bb3, label %bb2
     47 
     48 bb3:    ; preds = %bb1
     49   %15 = sub i32 %13, %len.0    ; <i32> [#uses=1]
     50   store i32 %15, i32* %8, align 4
     51   %16 = load i8** %9, align 4    ; <i8*> [#uses=1]
     52   %17 = getelementptr i8* %16, i32 %len.0   ; <i8*> [#uses=1]
     53   store i8* %17, i8** %10, align 4
     54   br label %bb4
     55 
     56 bb7:    ; preds = %bb4
     57   %18 = getelementptr %struct.mbuf* %mp, i32 0, i32 5   ; <i16*> [#uses=1]
     58   %19 = load i16* %18, align 2    ; <i16> [#uses=1]
     59   %20 = zext i16 %19 to i32   ; <i32> [#uses=1]
     60   %21 = and i32 %20, 2    ; <i32> [#uses=1]
     61   %22 = icmp eq i32 %21, 0    ; <i1> [#uses=1]
     62   br i1 %22, label %return, label %bb8
     63 
     64 bb8:    ; preds = %bb7
     65   %23 = sub i32 %req_len, %len.0    ; <i32> [#uses=1]
     66   %24 = getelementptr %struct.mbuf* %mp, i32 0, i32 6   ; <i32*> [#uses=1]
     67   store i32 %23, i32* %24, align 4
     68   ret void
     69 
     70 return:   ; preds = %bb7, %entry
     71   ret void
     72 }
     73