Dan Gohman | 0a06310 | 2009-09-08 23:54:48 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -march=x86-64 -stats |& \ |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2 | ; RUN: grep {6 .*Number of machine instrs printed} |
| 3 | |
| 4 | ;; Integer absolute value, should produce something at least as good as: |
| 5 | ;; movl %edi, %eax |
| 6 | ;; sarl $31, %eax |
| 7 | ;; addl %eax, %edi |
| 8 | ;; xorl %eax, %edi |
| 9 | ;; movl %edi, %eax |
| 10 | ;; ret |
Dale Johannesen | 6e04eac | 2008-03-31 23:20:09 +0000 | [diff] [blame] | 11 | define i32 @test(i32 %a) nounwind { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 12 | %tmp1neg = sub i32 0, %a |
| 13 | %b = icmp sgt i32 %a, -1 |
| 14 | %abs = select i1 %b, i32 %a, i32 %tmp1neg |
| 15 | ret i32 %abs |
| 16 | } |
| 17 | |