Home | History | Annotate | Download | only in NewGVN
      1 ; XFAIL: *
      2 ;; NewGVN zaps the strlens, but currently takes two iterations to evaluate the conditions, because
      3 ;; we prune predicateinfo, and the icmps only become equivalent after the strlens are zapped
      4 ; Two occurrences of strlen should be zapped.
      5 ; RUN: opt < %s -basicaa -newgvn -S | FileCheck %s
      6 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"
      7 target triple = "i386-apple-darwin9"
      8 
      9 define i32 @test(i32 %g, i8* %P) nounwind  {
     10 entry:
     11 	%tmp2 = call i32 @strlen( i8* %P ) nounwind readonly 		; <i32> [#uses=1]
     12 	%tmp3 = icmp eq i32 %tmp2, 100		; <i1> [#uses=1]
     13 	%tmp34 = zext i1 %tmp3 to i8		; <i8> [#uses=1]
     14 	%toBool = icmp ne i8 %tmp34, 0		; <i1> [#uses=1]
     15 	br i1 %toBool, label %bb, label %bb6
     16 
     17 bb:		; preds = %entry
     18 	br label %bb27
     19 
     20 bb6:		; preds = %entry
     21 	%tmp8 = add i32 %g, 42		; <i32> [#uses=2]
     22 	%tmp10 = call i32 @strlen( i8* %P ) nounwind readonly 		; <i32> [#uses=1]
     23 	%tmp11 = icmp eq i32 %tmp10, 100		; <i1> [#uses=1]
     24 	%tmp1112 = zext i1 %tmp11 to i8		; <i8> [#uses=1]
     25 	%toBool13 = icmp ne i8 %tmp1112, 0		; <i1> [#uses=1]
     26 	br i1 %toBool13, label %bb14, label %bb16
     27 
     28 bb14:		; preds = %bb6
     29 	br label %bb27
     30 
     31 bb16:		; preds = %bb6
     32 	%tmp18 = mul i32 %tmp8, 2		; <i32> [#uses=1]
     33 	%tmp20 = call i32 @strlen( i8* %P ) nounwind readonly 		; <i32> [#uses=1]
     34 	%tmp21 = icmp eq i32 %tmp20, 100		; <i1> [#uses=1]
     35 	%tmp2122 = zext i1 %tmp21 to i8		; <i8> [#uses=1]
     36 	%toBool23 = icmp ne i8 %tmp2122, 0		; <i1> [#uses=1]
     37 	br i1 %toBool23, label %bb24, label %bb26
     38 
     39 bb24:		; preds = %bb16
     40 	br label %bb27
     41 
     42 bb26:		; preds = %bb16
     43 	br label %bb27
     44 
     45 bb27:		; preds = %bb26, %bb24, %bb14, %bb
     46 	%tmp.0 = phi i32 [ 11, %bb26 ], [ %tmp18, %bb24 ], [ %tmp8, %bb14 ], [ %g, %bb ]		; <i32> [#uses=1]
     47 	br label %return
     48 
     49 return:		; preds = %bb27
     50 	ret i32 %tmp.0
     51 }
     52 
     53 ; CHECK: define i32 @test(i32 %g, i8* %P) #0 {
     54 ; CHECK: entry:
     55 ; CHECK:   %tmp2 = call i32 @strlen(i8* %P) #1
     56 ; CHECK:   %tmp3 = icmp eq i32 %tmp2, 100
     57 ; CHECK:   %tmp34 = zext i1 %tmp3 to i8
     58 ; CHECK:   br i1 %tmp3, label %bb, label %bb6
     59 ; CHECK: bb:
     60 ; CHECK:   br label %bb27
     61 ; CHECK: bb6:
     62 ; CHECK:   %tmp8 = add i32 %g, 42
     63 ; CHECK:   br i1 false, label %bb14, label %bb16
     64 ; CHECK: bb14:
     65 ; CHECK:   br label %bb27
     66 ; CHECK: bb16:
     67 ; CHECK:   %tmp18 = mul i32 %tmp8, 2
     68 ; CHECK:   br i1 false, label %bb24, label %bb26
     69 ; CHECK: bb24:
     70 ; CHECK:   br label %bb27
     71 ; CHECK: bb26:
     72 ; CHECK:   br label %bb27
     73 ; CHECK: bb27:
     74 ; CHECK:   %tmp.0 = phi i32 [ 11, %bb26 ], [ undef, %bb24 ], [ undef, %bb14 ], [ %g, %bb ]
     75 ; CHECK:   ret i32 %tmp.0
     76 ; CHECK: }
     77 
     78 declare i32 @strlen(i8*) nounwind readonly 
     79