blob: 542135529f1d0a2f8df6e31b588c6f432bee3477 [file] [log] [blame]
NAKAMURA Takumi22bc92b2011-02-22 07:20:26 +00001; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s
2; RUN: llc < %s -mtriple=x86_64-win32 | FileCheck %s
Tanya Lattner33eefff2008-02-21 07:42:26 +00003
Chris Lattner8047d762009-09-08 22:38:46 +00004define i32 @test1(i32 %x) nounwind {
5 %tmp1 = shl i32 %x, 3
6 %tmp2 = add i32 %tmp1, 7
Tanya Lattner33eefff2008-02-21 07:42:26 +00007 ret i32 %tmp2
Chris Lattner8047d762009-09-08 22:38:46 +00008; CHECK: test1:
NAKAMURA Takumi22bc92b2011-02-22 07:20:26 +00009; CHECK: leal 7(,[[A0:%rdi|%rcx]],8), %eax
Evan Chengdc7dd972006-05-30 06:53:55 +000010}
Tanya Lattner33eefff2008-02-21 07:42:26 +000011
Chris Lattner8047d762009-09-08 22:38:46 +000012
13; ISel the add of -4 with a neg and use an lea for the rest of the
14; arithemtic.
15define i32 @test2(i32 %x_offs) nounwind readnone {
16entry:
17 %t0 = icmp sgt i32 %x_offs, 4
18 br i1 %t0, label %bb.nph, label %bb2
19
20bb.nph:
21 %tmp = add i32 %x_offs, -5
22 %tmp6 = lshr i32 %tmp, 2
23 %tmp7 = mul i32 %tmp6, -4
24 %tmp8 = add i32 %tmp7, %x_offs
25 %tmp9 = add i32 %tmp8, -4
26 ret i32 %tmp9
27
28bb2:
29 ret i32 %x_offs
30; CHECK: test2:
NAKAMURA Takumi22bc92b2011-02-22 07:20:26 +000031; CHECK: leal -5([[A0]]), %eax
Chris Lattnerd8429622009-09-08 23:05:44 +000032; CHECK: andl $-4, %eax
Chris Lattner8047d762009-09-08 22:38:46 +000033; CHECK: negl %eax
NAKAMURA Takumi22bc92b2011-02-22 07:20:26 +000034; CHECK: leal -4([[A0]],%rax), %eax
Chris Lattner8047d762009-09-08 22:38:46 +000035}