blob: a8ba0155fd10e4a12bd008870c6c23201e673a51 [file] [log] [blame]
Dan Gohman36a09472009-09-08 23:54:48 +00001; RUN: llc < %s -march=x86-64 -stats |& \
Evan Chengf06e6c22011-03-02 01:08:17 +00002; RUN: grep {5 .*Number of machine instrs printed}
Chris Lattner603572a2007-04-11 05:02:57 +00003
4;; Integer absolute value, should produce something at least as good as:
Evan Chengf06e6c22011-03-02 01:08:17 +00005;; movl %edi, %ecx
6;; sarl $31, %ecx
7;; leal (%rdi,%rcx), %eax
8;; xorl %ecx, %eax
Chris Lattner603572a2007-04-11 05:02:57 +00009;; ret
Dale Johannesen1d3863f2008-03-31 23:20:09 +000010define i32 @test(i32 %a) nounwind {
Chris Lattner603572a2007-04-11 05:02:57 +000011 %tmp1neg = sub i32 0, %a
12 %b = icmp sgt i32 %a, -1
13 %abs = select i1 %b, i32 %a, i32 %tmp1neg
14 ret i32 %abs
15}
16