1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-linux-gnu -fast-isel=0 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,ISEL
3 ; RUN: llc -mtriple=aarch64-linux-gnu -fast-isel=1 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,FAST
5 define i32 @test1(i32 %x) {
8 ; CHECK-NEXT: add w8, w0, #7
9 ; CHECK-NEXT: cmp w0, #0
10 ; CHECK-NEXT: csel w8, w8, w0, lt
11 ; CHECK-NEXT: asr w0, w8, #3
17 define i32 @test2(i32 %x) {
20 ; CHECK-NEXT: add w8, w0, #7
21 ; CHECK-NEXT: cmp w0, #0
22 ; CHECK-NEXT: csel w8, w8, w0, lt
23 ; CHECK-NEXT: neg w0, w8, asr #3
25 %div = sdiv i32 %x, -8
29 define i32 @test3(i32 %x) {
32 ; CHECK-NEXT: add w8, w0, #31
33 ; CHECK-NEXT: cmp w0, #0
34 ; CHECK-NEXT: csel w8, w8, w0, lt
35 ; CHECK-NEXT: asr w0, w8, #5
37 %div = sdiv i32 %x, 32
41 define i64 @test4(i64 %x) {
44 ; CHECK-NEXT: add x8, x0, #7
45 ; CHECK-NEXT: cmp x0, #0
46 ; CHECK-NEXT: csel x8, x8, x0, lt
47 ; CHECK-NEXT: asr x0, x8, #3
53 define i64 @test5(i64 %x) {
56 ; CHECK-NEXT: add x8, x0, #7
57 ; CHECK-NEXT: cmp x0, #0
58 ; CHECK-NEXT: csel x8, x8, x0, lt
59 ; CHECK-NEXT: neg x0, x8, asr #3
61 %div = sdiv i64 %x, -8
65 define i64 @test6(i64 %x) {
68 ; CHECK-NEXT: add x8, x0, #63
69 ; CHECK-NEXT: cmp x0, #0
70 ; CHECK-NEXT: csel x8, x8, x0, lt
71 ; CHECK-NEXT: asr x0, x8, #6
73 %div = sdiv i64 %x, 64
77 define i64 @test7(i64 %x) {
80 ; CHECK-NEXT: mov x8, #281474976710655 // =0xffffffffffff
81 ; CHECK-NEXT: cmp x0, #0
82 ; CHECK-NEXT: add x8, x0, x8
83 ; CHECK-NEXT: csel x8, x8, x0, lt
84 ; CHECK-NEXT: asr x0, x8, #48
86 %div = sdiv i64 %x, 281474976710656
90 define i64 @test8(i64 %x) {
93 ; ISEL-NEXT: add x8, x0, x0, lsr #63
94 ; ISEL-NEXT: asr x0, x8, #1
99 ; FAST-NEXT: add x8, x0, #1
100 ; FAST-NEXT: cmp x0, #0
101 ; FAST-NEXT: csel x8, x8, x0, lt
102 ; FAST-NEXT: asr x0, x8, #1
104 %div = sdiv i64 %x, 2
108 define i32 @sdiv_int(i32 %begin, i32 %first) #0 {
109 ; ISEL-LABEL: sdiv_int:
111 ; ISEL-NEXT: sub w8, w0, w1
112 ; ISEL-NEXT: add w8, w8, #1
113 ; ISEL-NEXT: add w8, w8, w8, lsr #31
114 ; ISEL-NEXT: sub w0, w0, w8, asr #1
117 ; FAST-LABEL: sdiv_int:
119 ; FAST-NEXT: add w8, w0, #1
120 ; FAST-NEXT: sub w8, w8, w1
121 ; FAST-NEXT: add w9, w8, #1
122 ; FAST-NEXT: cmp w8, #0
123 ; FAST-NEXT: csel w8, w9, w8, lt
124 ; FAST-NEXT: neg w8, w8, asr #1
125 ; FAST-NEXT: add w0, w8, w0
127 %sub = add i32 %begin, 1
128 %add = sub i32 %sub, %first
129 %div.neg = sdiv i32 %add, -2
130 %sub1 = add i32 %div.neg, %begin
134 attributes #0 = { "target-features"="+sve" vscale_range(2,2) }