194 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc -mtriple=aarch64-linux-gnu -fast-isel=0 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,ISEL3; RUN: llc -mtriple=aarch64-linux-gnu -fast-isel=1 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,FAST4 5define i32 @test1(i32 %x) {6; ISEL-LABEL: test1:7; ISEL: // %bb.0:8; ISEL-NEXT: add w8, w0, #79; ISEL-NEXT: cmp w0, #010; ISEL-NEXT: csel w8, w8, w0, mi11; ISEL-NEXT: asr w0, w8, #312; ISEL-NEXT: ret13;14; FAST-LABEL: test1:15; FAST: // %bb.0:16; FAST-NEXT: add w8, w0, #717; FAST-NEXT: cmp w0, #018; FAST-NEXT: csel w8, w8, w0, lt19; FAST-NEXT: asr w0, w8, #320; FAST-NEXT: ret21 %div = sdiv i32 %x, 822 ret i32 %div23}24 25define i32 @test2(i32 %x) {26; ISEL-LABEL: test2:27; ISEL: // %bb.0:28; ISEL-NEXT: add w8, w0, #729; ISEL-NEXT: cmp w0, #030; ISEL-NEXT: csel w8, w8, w0, mi31; ISEL-NEXT: neg w0, w8, asr #332; ISEL-NEXT: ret33;34; FAST-LABEL: test2:35; FAST: // %bb.0:36; FAST-NEXT: add w8, w0, #737; FAST-NEXT: cmp w0, #038; FAST-NEXT: csel w8, w8, w0, lt39; FAST-NEXT: neg w0, w8, asr #340; FAST-NEXT: ret41 %div = sdiv i32 %x, -842 ret i32 %div43}44 45define i32 @test3(i32 %x) {46; ISEL-LABEL: test3:47; ISEL: // %bb.0:48; ISEL-NEXT: add w8, w0, #3149; ISEL-NEXT: cmp w0, #050; ISEL-NEXT: csel w8, w8, w0, mi51; ISEL-NEXT: asr w0, w8, #552; ISEL-NEXT: ret53;54; FAST-LABEL: test3:55; FAST: // %bb.0:56; FAST-NEXT: add w8, w0, #3157; FAST-NEXT: cmp w0, #058; FAST-NEXT: csel w8, w8, w0, lt59; FAST-NEXT: asr w0, w8, #560; FAST-NEXT: ret61 %div = sdiv i32 %x, 3262 ret i32 %div63}64 65define i64 @test4(i64 %x) {66; ISEL-LABEL: test4:67; ISEL: // %bb.0:68; ISEL-NEXT: add x8, x0, #769; ISEL-NEXT: cmp x0, #070; ISEL-NEXT: csel x8, x8, x0, mi71; ISEL-NEXT: asr x0, x8, #372; ISEL-NEXT: ret73;74; FAST-LABEL: test4:75; FAST: // %bb.0:76; FAST-NEXT: add x8, x0, #777; FAST-NEXT: cmp x0, #078; FAST-NEXT: csel x8, x8, x0, lt79; FAST-NEXT: asr x0, x8, #380; FAST-NEXT: ret81 %div = sdiv i64 %x, 882 ret i64 %div83}84 85define i64 @test5(i64 %x) {86; ISEL-LABEL: test5:87; ISEL: // %bb.0:88; ISEL-NEXT: add x8, x0, #789; ISEL-NEXT: cmp x0, #090; ISEL-NEXT: csel x8, x8, x0, mi91; ISEL-NEXT: neg x0, x8, asr #392; ISEL-NEXT: ret93;94; FAST-LABEL: test5:95; FAST: // %bb.0:96; FAST-NEXT: add x8, x0, #797; FAST-NEXT: cmp x0, #098; FAST-NEXT: csel x8, x8, x0, lt99; FAST-NEXT: neg x0, x8, asr #3100; FAST-NEXT: ret101 %div = sdiv i64 %x, -8102 ret i64 %div103}104 105define i64 @test6(i64 %x) {106; ISEL-LABEL: test6:107; ISEL: // %bb.0:108; ISEL-NEXT: add x8, x0, #63109; ISEL-NEXT: cmp x0, #0110; ISEL-NEXT: csel x8, x8, x0, mi111; ISEL-NEXT: asr x0, x8, #6112; ISEL-NEXT: ret113;114; FAST-LABEL: test6:115; FAST: // %bb.0:116; FAST-NEXT: add x8, x0, #63117; FAST-NEXT: cmp x0, #0118; FAST-NEXT: csel x8, x8, x0, lt119; FAST-NEXT: asr x0, x8, #6120; FAST-NEXT: ret121 %div = sdiv i64 %x, 64122 ret i64 %div123}124 125define i64 @test7(i64 %x) {126; ISEL-LABEL: test7:127; ISEL: // %bb.0:128; ISEL-NEXT: mov x8, #281474976710655 // =0xffffffffffff129; ISEL-NEXT: cmp x0, #0130; ISEL-NEXT: add x8, x0, x8131; ISEL-NEXT: csel x8, x8, x0, mi132; ISEL-NEXT: asr x0, x8, #48133; ISEL-NEXT: ret134;135; FAST-LABEL: test7:136; FAST: // %bb.0:137; FAST-NEXT: mov x8, #281474976710655 // =0xffffffffffff138; FAST-NEXT: cmp x0, #0139; FAST-NEXT: add x8, x0, x8140; FAST-NEXT: csel x8, x8, x0, lt141; FAST-NEXT: asr x0, x8, #48142; FAST-NEXT: ret143 %div = sdiv i64 %x, 281474976710656144 ret i64 %div145}146 147define i64 @test8(i64 %x) {148; ISEL-LABEL: test8:149; ISEL: // %bb.0:150; ISEL-NEXT: add x8, x0, x0, lsr #63151; ISEL-NEXT: asr x0, x8, #1152; ISEL-NEXT: ret153;154; FAST-LABEL: test8:155; FAST: // %bb.0:156; FAST-NEXT: add x8, x0, #1157; FAST-NEXT: cmp x0, #0158; FAST-NEXT: csel x8, x8, x0, lt159; FAST-NEXT: asr x0, x8, #1160; FAST-NEXT: ret161 %div = sdiv i64 %x, 2162 ret i64 %div163}164 165define i32 @sdiv_int(i32 %begin, i32 %first) #0 {166; ISEL-LABEL: sdiv_int:167; ISEL: // %bb.0:168; ISEL-NEXT: sub w8, w0, w1169; ISEL-NEXT: add w8, w8, #1170; ISEL-NEXT: add w8, w8, w8, lsr #31171; ISEL-NEXT: sub w0, w0, w8, asr #1172; ISEL-NEXT: ret173;174; FAST-LABEL: sdiv_int:175; FAST: // %bb.0:176; FAST-NEXT: add w8, w0, #1177; FAST-NEXT: sub w8, w8, w1178; FAST-NEXT: add w9, w8, #1179; FAST-NEXT: cmp w8, #0180; FAST-NEXT: csel w8, w9, w8, lt181; FAST-NEXT: neg w8, w8, asr #1182; FAST-NEXT: add w0, w8, w0183; FAST-NEXT: ret184 %sub = add i32 %begin, 1185 %add = sub i32 %sub, %first186 %div.neg = sdiv i32 %add, -2187 %sub1 = add i32 %div.neg, %begin188 ret i32 %sub1189}190 191attributes #0 = { "target-features"="+sve" vscale_range(2,2) }192;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:193; CHECK: {{.*}}194