[X86] Replace LEAs with INC/DEC when profitable
[oota-llvm.git] / test / CodeGen / X86 / fixup-lea.ll
1 ;RUN: llc < %s -march=x86 | FileCheck %s
2
3 define void @foo(i32 inreg %dns) minsize {
4 entry:
5 ; CHECK-LABEL: foo
6 ; CHECK: dec
7   br label %for.body
8
9 for.body:
10   %i.05 = phi i16 [ %dec, %for.body ], [ 0, %entry ]
11   %dec = add i16 %i.05, -1
12   %conv = zext i16 %dec to i32
13   %cmp = icmp slt i32 %conv, %dns
14   br i1 %cmp, label %for.body, label %for.end
15
16 for.end:
17   ret void
18 }
19
20 define void @bar(i32 inreg %dns) minsize {
21 entry:
22 ; CHECK-LABEL: bar
23 ; CHECK: inc
24   br label %for.body
25
26 for.body:
27   %i.05 = phi i16 [ %inc, %for.body ], [ 0, %entry ]
28   %inc = add i16 %i.05, 1
29   %conv = zext i16 %inc to i32
30   %cmp = icmp slt i32 %conv, %dns
31   br i1 %cmp, label %for.body, label %for.end
32 for.end:
33   ret void
34 }