1 ; RUN: llc -mtriple=armv7a -mattr=+hwdiv-arm %s -o - | FileCheck %s --check-prefixes=CHECK,DIV
2 ; RUN: llc -mtriple=armv7a -mattr=-hwdiv-arm %s -o - | FileCheck %s --check-prefixes=CHECK,NODIV
5 define dso_local i32 @test_rem(i32 %F) local_unnamed_addr #0 {
6 ; CHECK-LABEL: test_rem
7 ; CHECK: asr r1, r0, #31
8 ; CHECK-NEXT: add r1, r0, r1, lsr #30
9 ; CHECK-NEXT: bic r1, r1, #3
10 ; CHECK-NEXT: sub r0, r0, r1
17 ; Try an i16 sdiv, with a small immediate.
18 define dso_local signext i16 @f0(i16 signext %F) local_unnamed_addr #0 {
22 ; DIV-NEXT: sdiv r0, r0, r1
23 ; DIV-NEXT: sxth r0, r0
27 ; NODIV-NEXT: add r0, r0, r1, lsr #15
28 ; NODIV-NEXT: sxth r0, r0
29 ; NODIV-NEXT: asr r0, r0, #1
37 ; Try an i32 sdiv, with a small immediate.
38 define dso_local i32 @f1(i32 %F) local_unnamed_addr #0 {
42 ; DIV-NEXT: sdiv r0, r0, r1
45 ; NODIV: asr r1, r0, #31
46 ; NODIV-NEXT: add r0, r0, r1, lsr #30
47 ; NODIV-NEXT: asr r0, r0, #2
55 ; Try a large power of 2 immediate, which should also be materialised with 1
56 ; move immediate instruction.
57 define dso_local i32 @f2(i32 %F) local_unnamed_addr #0 {
59 ; DIV: mov r1, #131072
60 ; DIV-NEXT: sdiv r0, r0, r1
63 %div = sdiv i32 %F, 131072
67 ; MinSize not set, so should expand to the faster but longer sequence.
68 define dso_local i32 @f3(i32 %F) {
70 ; CHECK: asr r1, r0, #31
71 ; CHECK-NEXT: add r0, r0, r1, lsr #30
72 ; CHECK-NEXT: asr r0, r0, #2
79 attributes #0 = { minsize norecurse nounwind optsize readnone }