1 ; RUN: llc -mtriple=arm-eabi -mattr=+v4t %s -o - | FileCheck %s
3 ;; Integer absolute value, should produce something as good as: ARM:
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
14 ; CHECK: rsbmi r0, r0, #0
19 ;; 3 instructions will be generated for abs(a-b):
23 define i32 @test2(i32 %a, i32 %b) nounwind readnone ssp {
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
36 define i64 @test3(i64 %a) {
39 ; CHECK-NEXT: eor r0, r0, r1, asr #31
40 ; CHECK-NEXT: eor r2, r1, r1, asr #31
41 ; CHECK-NEXT: subs r0, r0, r1, asr #31
42 ; CHECK-NEXT: sbc r1, r2, r1, asr #31
44 %tmp1neg = sub i64 0, %a
45 %b = icmp sgt i64 %a, -1
46 %abs = select i1 %b, i64 %a, i64 %tmp1neg