Dan Gohman | 1d36798 | 2010-04-24 03:13:44 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -march=x86-64 | FileCheck %s |
| 2 | |
| 3 | ; LSR's OptimizeMax should eliminate the select (max). |
| 4 | |
| 5 | ; CHECK: foo: |
| 6 | ; CHECK-NOT: cmov |
| 7 | ; CHECK: jle |
| 8 | |
| 9 | define void @foo(i64 %n, double* nocapture %p) nounwind { |
| 10 | entry: |
| 11 | %cmp6 = icmp slt i64 %n, 0 ; <i1> [#uses=1] |
| 12 | br i1 %cmp6, label %for.end, label %for.body.preheader |
| 13 | |
| 14 | for.body.preheader: ; preds = %entry |
| 15 | %tmp = icmp sgt i64 %n, 0 ; <i1> [#uses=1] |
| 16 | %n.op = add i64 %n, 1 ; <i64> [#uses=1] |
| 17 | %tmp1 = select i1 %tmp, i64 %n.op, i64 1 ; <i64> [#uses=1] |
| 18 | br label %for.body |
| 19 | |
| 20 | for.body: ; preds = %for.body.preheader, %for.body |
| 21 | %i = phi i64 [ %i.next, %for.body ], [ 0, %for.body.preheader ] ; <i64> [#uses=2] |
| 22 | %arrayidx = getelementptr double* %p, i64 %i ; <double*> [#uses=2] |
| 23 | %t4 = load double* %arrayidx ; <double> [#uses=1] |
| 24 | %mul = fmul double %t4, 2.200000e+00 ; <double> [#uses=1] |
| 25 | store double %mul, double* %arrayidx |
| 26 | %i.next = add nsw i64 %i, 1 ; <i64> [#uses=2] |
| 27 | %exitcond = icmp eq i64 %i.next, %tmp1 ; <i1> [#uses=1] |
| 28 | br i1 %exitcond, label %for.end, label %for.body |
| 29 | |
| 30 | for.end: ; preds = %for.body, %entry |
| 31 | ret void |
| 32 | } |