1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-linux-gnu -mcpu=ppc64 < %s | FileCheck --check-prefix=CHECK %s
3 ; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-linux-gnu -mcpu=ppc < %s | FileCheck --check-prefix=CHECK %s
5 define i32 @fold_urem_positive_odd(i32 %x) {
6 ; CHECK-LABEL: fold_urem_positive_odd:
8 ; CHECK-NEXT: lis 4, 22765
9 ; CHECK-NEXT: ori 4, 4, 8969
10 ; CHECK-NEXT: mulhwu 4, 3, 4
11 ; CHECK-NEXT: sub 5, 3, 4
12 ; CHECK-NEXT: srwi 5, 5, 1
13 ; CHECK-NEXT: add 4, 5, 4
14 ; CHECK-NEXT: srwi 4, 4, 6
15 ; CHECK-NEXT: mulli 4, 4, 95
16 ; CHECK-NEXT: sub 3, 3, 4
23 define i32 @fold_urem_positive_even(i32 %x) {
24 ; CHECK-LABEL: fold_urem_positive_even:
26 ; CHECK-NEXT: lis 4, -2226
27 ; CHECK-NEXT: ori 4, 4, 16323
28 ; CHECK-NEXT: mulhwu 4, 3, 4
29 ; CHECK-NEXT: srwi 4, 4, 10
30 ; CHECK-NEXT: mulli 4, 4, 1060
31 ; CHECK-NEXT: sub 3, 3, 4
33 %1 = urem i32 %x, 1060
38 ; Don't fold if we can combine urem with udiv.
39 define i32 @combine_urem_udiv(i32 %x) {
40 ; CHECK-LABEL: combine_urem_udiv:
42 ; CHECK-NEXT: lis 4, 22765
43 ; CHECK-NEXT: ori 4, 4, 8969
44 ; CHECK-NEXT: mulhwu 4, 3, 4
45 ; CHECK-NEXT: sub 5, 3, 4
46 ; CHECK-NEXT: srwi 5, 5, 1
47 ; CHECK-NEXT: add 4, 5, 4
48 ; CHECK-NEXT: srwi 4, 4, 6
49 ; CHECK-NEXT: mulli 5, 4, 95
50 ; CHECK-NEXT: sub 3, 3, 5
51 ; CHECK-NEXT: add 3, 3, 4
59 ; Don't fold for divisors that are a power of two.
60 define i32 @dont_fold_urem_power_of_two(i32 %x) {
61 ; CHECK-LABEL: dont_fold_urem_power_of_two:
63 ; CHECK-NEXT: clrlwi 3, 3, 26
69 ; Don't fold if the divisor is one.
70 define i32 @dont_fold_urem_one(i32 %x) {
71 ; CHECK-LABEL: dont_fold_urem_one:
79 ; Don't fold if the divisor is 2^32.
80 define i32 @dont_fold_urem_i32_umax(i32 %x) {
81 ; CHECK-LABEL: dont_fold_urem_i32_umax:
84 %1 = urem i32 %x, 4294967296
89 define i64 @dont_fold_urem_i64(i64 %x) {
90 ; CHECK-LABEL: dont_fold_urem_i64:
93 ; CHECK-NEXT: stwu 1, -16(1)
94 ; CHECK-NEXT: stw 0, 20(1)
95 ; CHECK-NEXT: .cfi_def_cfa_offset 16
96 ; CHECK-NEXT: .cfi_offset lr, 4
98 ; CHECK-NEXT: li 6, 98
99 ; CHECK-NEXT: bl __umoddi3
100 ; CHECK-NEXT: lwz 0, 20(1)
101 ; CHECK-NEXT: addi 1, 1, 16