1 ; RUN: llc < %s -march=x86-64 | not grep cmov 2 3 ; LSR should be able to eliminate both smax and umax expressions 4 ; in loop trip counts. 5 6 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" 7 8 define void @fs(double* nocapture %p, i64 %n) nounwind { 9 entry: 10 %tmp = icmp slt i64 %n, 1 ; <i1> [#uses=1] 11 %smax = select i1 %tmp, i64 1, i64 %n ; <i64> [#uses=1] 12 br label %bb 13 14 bb: ; preds = %bb, %entry 15 %i.0 = phi i64 [ 0, %entry ], [ %0, %bb ] ; <i64> [#uses=2] 16 %scevgep = getelementptr double* %p, i64 %i.0 ; <double*> [#uses=1] 17 store double 0.000000e+00, double* %scevgep, align 8 18 %0 = add i64 %i.0, 1 ; <i64> [#uses=2] 19 %exitcond = icmp eq i64 %0, %smax ; <i1> [#uses=1] 20 br i1 %exitcond, label %return, label %bb 21 22 return: ; preds = %bb 23 ret void 24 } 25 26 define void @bs(double* nocapture %p, i64 %n) nounwind { 27 entry: 28 %tmp = icmp sge i64 %n, 1 ; <i1> [#uses=1] 29 %smax = select i1 %tmp, i64 %n, i64 1 ; <i64> [#uses=1] 30 br label %bb 31 32 bb: ; preds = %bb, %entry 33 %i.0 = phi i64 [ 0, %entry ], [ %0, %bb ] ; <i64> [#uses=2] 34 %scevgep = getelementptr double* %p, i64 %i.0 ; <double*> [#uses=1] 35 store double 0.000000e+00, double* %scevgep, align 8 36 %0 = add i64 %i.0, 1 ; <i64> [#uses=2] 37 %exitcond = icmp eq i64 %0, %smax ; <i1> [#uses=1] 38 br i1 %exitcond, label %return, label %bb 39 40 return: ; preds = %bb 41 ret void 42 } 43 44 define void @fu(double* nocapture %p, i64 %n) nounwind { 45 entry: 46 %tmp = icmp eq i64 %n, 0 ; <i1> [#uses=1] 47 %umax = select i1 %tmp, i64 1, i64 %n ; <i64> [#uses=1] 48 br label %bb 49 50 bb: ; preds = %bb, %entry 51 %i.0 = phi i64 [ 0, %entry ], [ %0, %bb ] ; <i64> [#uses=2] 52 %scevgep = getelementptr double* %p, i64 %i.0 ; <double*> [#uses=1] 53 store double 0.000000e+00, double* %scevgep, align 8 54 %0 = add i64 %i.0, 1 ; <i64> [#uses=2] 55 %exitcond = icmp eq i64 %0, %umax ; <i1> [#uses=1] 56 br i1 %exitcond, label %return, label %bb 57 58 return: ; preds = %bb 59 ret void 60 } 61 62 define void @bu(double* nocapture %p, i64 %n) nounwind { 63 entry: 64 %tmp = icmp ne i64 %n, 0 ; <i1> [#uses=1] 65 %umax = select i1 %tmp, i64 %n, i64 1 ; <i64> [#uses=1] 66 br label %bb 67 68 bb: ; preds = %bb, %entry 69 %i.0 = phi i64 [ 0, %entry ], [ %0, %bb ] ; <i64> [#uses=2] 70 %scevgep = getelementptr double* %p, i64 %i.0 ; <double*> [#uses=1] 71 store double 0.000000e+00, double* %scevgep, align 8 72 %0 = add i64 %i.0, 1 ; <i64> [#uses=2] 73 %exitcond = icmp eq i64 %0, %umax ; <i1> [#uses=1] 74 br i1 %exitcond, label %return, label %bb 75 76 return: ; preds = %bb 77 ret void 78 } 79