Home | History | Annotate | Download | only in ARM
      1 ; RUN: llc < %s -march=arm -mattr=+v4t | FileCheck %s
      2 
      3 ;; Integer absolute value, should produce something as good as: ARM:
      4 ;;   movs r0, r0
      5 ;;   rsbmi r0, r0, #0
      6 ;;   bx lr
      7 
      8 define i32 @test(i32 %a) {
      9         %tmp1neg = sub i32 0, %a
     10         %b = icmp sgt i32 %a, -1
     11         %abs = select i1 %b, i32 %a, i32 %tmp1neg
     12         ret i32 %abs
     13 ; CHECK:  cmp
     14 ; CHECK:  rsbmi r0, r0, #0
     15 ; CHECK:  bx lr
     16 }
     17 
     18 ; rdar://11633193
     19 ;; 3 instructions will be generated for abs(a-b):
     20 ;;   subs
     21 ;;   rsbmi
     22 ;;   bx
     23 define i32 @test2(i32 %a, i32 %b) nounwind readnone ssp {
     24 entry:
     25 ; CHECK: test2
     26 ; CHECK: subs
     27 ; CHECK-NEXT: rsbmi
     28 ; CHECK-NEXT: bx
     29   %sub = sub nsw i32 %a, %b
     30   %cmp = icmp sgt i32 %sub, -1
     31   %sub1 = sub nsw i32 0, %sub
     32   %cond = select i1 %cmp, i32 %sub, i32 %sub1
     33   ret i32 %cond
     34 }
     35