blob: 1b295a4265ee2487a7a25edda60ce1d15cdca6a8 [file] [log] [blame]
Chris Lattner8047d762009-09-08 22:38:46 +00001; RUN: llvm-as < %s | llc -march=x86-64 | FileCheck %s
Tanya Lattner33eefff2008-02-21 07:42:26 +00002
Chris Lattner8047d762009-09-08 22:38:46 +00003define i32 @test1(i32 %x) nounwind {
4 %tmp1 = shl i32 %x, 3
5 %tmp2 = add i32 %tmp1, 7
Tanya Lattner33eefff2008-02-21 07:42:26 +00006 ret i32 %tmp2
Chris Lattner8047d762009-09-08 22:38:46 +00007; CHECK: test1:
8; CHECK: leal 7(,%rdi,8), %eax
Evan Chengdc7dd972006-05-30 06:53:55 +00009}
Tanya Lattner33eefff2008-02-21 07:42:26 +000010
Chris Lattner8047d762009-09-08 22:38:46 +000011
12; ISel the add of -4 with a neg and use an lea for the rest of the
13; arithemtic.
14define i32 @test2(i32 %x_offs) nounwind readnone {
15entry:
16 %t0 = icmp sgt i32 %x_offs, 4
17 br i1 %t0, label %bb.nph, label %bb2
18
19bb.nph:
20 %tmp = add i32 %x_offs, -5
21 %tmp6 = lshr i32 %tmp, 2
22 %tmp7 = mul i32 %tmp6, -4
23 %tmp8 = add i32 %tmp7, %x_offs
24 %tmp9 = add i32 %tmp8, -4
25 ret i32 %tmp9
26
27bb2:
28 ret i32 %x_offs
29; CHECK: test2:
30; CHECK: leal -5(%rdi), %eax
31; CHECK: andl $4294967292, %eax
32; CHECK: negl %eax
33; CHECK: leal -4(%rdi,%rax), %eax
34}