1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -ppc-gpr-icmps=all -verify-machineinstrs -mcpu=pwr8 < %s | FileCheck %s
3 target datalayout = "e-m:e-i64:64-n32:64"
4 target triple = "powerpc64le-unknown-linux-gnu"
6 @zeroEqualityTest01.buffer1 = private unnamed_addr constant [3 x i32] [i32 1, i32 2, i32 4], align 4
7 @zeroEqualityTest01.buffer2 = private unnamed_addr constant [3 x i32] [i32 1, i32 2, i32 3], align 4
8 @zeroEqualityTest02.buffer1 = private unnamed_addr constant [4 x i32] [i32 4, i32 0, i32 0, i32 0], align 4
9 @zeroEqualityTest02.buffer2 = private unnamed_addr constant [4 x i32] [i32 3, i32 0, i32 0, i32 0], align 4
10 @zeroEqualityTest03.buffer1 = private unnamed_addr constant [4 x i32] [i32 0, i32 0, i32 0, i32 3], align 4
11 @zeroEqualityTest03.buffer2 = private unnamed_addr constant [4 x i32] [i32 0, i32 0, i32 0, i32 4], align 4
12 @zeroEqualityTest04.buffer1 = private unnamed_addr constant [15 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14], align 4
13 @zeroEqualityTest04.buffer2 = private unnamed_addr constant [15 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 13], align 4
15 declare signext i32 @memcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #1
17 ; Check 4 bytes - requires 1 load for each param.
18 define signext i32 @zeroEqualityTest02(ptr %x, ptr %y) {
19 ; CHECK-LABEL: zeroEqualityTest02:
21 ; CHECK-NEXT: lwz 3, 0(3)
22 ; CHECK-NEXT: lwz 4, 0(4)
23 ; CHECK-NEXT: xor 3, 3, 4
24 ; CHECK-NEXT: cntlzw 3, 3
25 ; CHECK-NEXT: srwi 3, 3, 5
26 ; CHECK-NEXT: xori 3, 3, 1
28 %call = tail call signext i32 @memcmp(ptr %x, ptr %y, i64 4)
29 %not.cmp = icmp ne i32 %call, 0
30 %. = zext i1 %not.cmp to i32
34 ; Check 16 bytes - requires 2 loads for each param (or use vectors?).
35 define signext i32 @zeroEqualityTest01(ptr %x, ptr %y) {
36 ; CHECK-LABEL: zeroEqualityTest01:
38 ; CHECK-NEXT: ld 5, 0(3)
39 ; CHECK-NEXT: ld 6, 0(4)
40 ; CHECK-NEXT: cmpld 5, 6
41 ; CHECK-NEXT: bne 0, .LBB1_2
42 ; CHECK-NEXT: # %bb.1: # %loadbb1
43 ; CHECK-NEXT: ld 5, 8(3)
44 ; CHECK-NEXT: ld 4, 8(4)
46 ; CHECK-NEXT: cmpld 5, 4
48 ; CHECK-NEXT: .LBB1_2: # %res_block
51 %call = tail call signext i32 @memcmp(ptr %x, ptr %y, i64 16)
52 %not.tobool = icmp ne i32 %call, 0
53 %. = zext i1 %not.tobool to i32
57 ; Check 7 bytes - requires 3 loads for each param.
58 define signext i32 @zeroEqualityTest03(ptr %x, ptr %y) {
59 ; CHECK-LABEL: zeroEqualityTest03:
61 ; CHECK-NEXT: lwz 5, 0(3)
62 ; CHECK-NEXT: lwz 6, 0(4)
63 ; CHECK-NEXT: cmplw 5, 6
64 ; CHECK-NEXT: bne 0, .LBB2_3
65 ; CHECK-NEXT: # %bb.1: # %loadbb1
66 ; CHECK-NEXT: lhz 5, 4(3)
67 ; CHECK-NEXT: lhz 6, 4(4)
68 ; CHECK-NEXT: cmplw 5, 6
69 ; CHECK-NEXT: bne 0, .LBB2_3
70 ; CHECK-NEXT: # %bb.2: # %loadbb2
71 ; CHECK-NEXT: lbz 5, 6(3)
72 ; CHECK-NEXT: lbz 4, 6(4)
74 ; CHECK-NEXT: cmplw 5, 4
76 ; CHECK-NEXT: .LBB2_3: # %res_block
79 %call = tail call signext i32 @memcmp(ptr %x, ptr %y, i64 7)
80 %not.lnot = icmp ne i32 %call, 0
81 %cond = zext i1 %not.lnot to i32
86 define signext i32 @zeroEqualityTest04() {
87 ; CHECK-LABEL: zeroEqualityTest04:
88 ; CHECK: # %bb.0: # %loadbb
91 %call = tail call signext i32 @memcmp(ptr @zeroEqualityTest02.buffer1, ptr @zeroEqualityTest02.buffer2, i64 16)
92 %not.cmp = icmp slt i32 %call, 1
93 %. = zext i1 %not.cmp to i32
98 define signext i32 @zeroEqualityTest05() {
99 ; CHECK-LABEL: zeroEqualityTest05:
100 ; CHECK: # %bb.0: # %loadbb
101 ; CHECK-NEXT: li 3, 0
103 %call = tail call signext i32 @memcmp(ptr @zeroEqualityTest03.buffer1, ptr @zeroEqualityTest03.buffer2, i64 16)
104 %call.lobit = lshr i32 %call, 31
105 %call.lobit.not = xor i32 %call.lobit, 1
106 ret i32 %call.lobit.not
109 ; Validate with memcmp()?:
110 define signext i32 @equalityFoldTwoConstants() {
111 ; CHECK-LABEL: equalityFoldTwoConstants:
112 ; CHECK: # %bb.0: # %loadbb
113 ; CHECK-NEXT: li 3, 1
115 %call = tail call signext i32 @memcmp(ptr @zeroEqualityTest04.buffer1, ptr @zeroEqualityTest04.buffer2, i64 16)
116 %not.tobool = icmp eq i32 %call, 0
117 %cond = zext i1 %not.tobool to i32
121 define signext i32 @equalityFoldOneConstant(ptr %X) {
122 ; CHECK-LABEL: equalityFoldOneConstant:
124 ; CHECK-NEXT: li 5, 1
125 ; CHECK-NEXT: ld 4, 0(3)
126 ; CHECK-NEXT: rldic 5, 5, 32, 31
127 ; CHECK-NEXT: cmpld 4, 5
128 ; CHECK-NEXT: bne 0, .LBB6_2
129 ; CHECK-NEXT: # %bb.1: # %loadbb1
130 ; CHECK-NEXT: lis 5, -32768
131 ; CHECK-NEXT: ld 4, 8(3)
132 ; CHECK-NEXT: li 3, 0
133 ; CHECK-NEXT: ori 5, 5, 1
134 ; CHECK-NEXT: rldic 5, 5, 1, 30
135 ; CHECK-NEXT: cmpld 4, 5
136 ; CHECK-NEXT: beq 0, .LBB6_3
137 ; CHECK-NEXT: .LBB6_2: # %res_block
138 ; CHECK-NEXT: li 3, 1
139 ; CHECK-NEXT: .LBB6_3: # %endblock
140 ; CHECK-NEXT: cntlzw 3, 3
141 ; CHECK-NEXT: srwi 3, 3, 5
143 %call = tail call signext i32 @memcmp(ptr @zeroEqualityTest04.buffer1, ptr %X, i64 16)
144 %not.tobool = icmp eq i32 %call, 0
145 %cond = zext i1 %not.tobool to i32
149 define i1 @length2_eq_nobuiltin_attr(ptr %X, ptr %Y) nounwind {
150 ; CHECK-LABEL: length2_eq_nobuiltin_attr:
153 ; CHECK-NEXT: stdu 1, -32(1)
154 ; CHECK-NEXT: li 5, 2
155 ; CHECK-NEXT: std 0, 48(1)
156 ; CHECK-NEXT: bl memcmp
158 ; CHECK-NEXT: cntlzw 3, 3
159 ; CHECK-NEXT: rlwinm 3, 3, 27, 31, 31
160 ; CHECK-NEXT: addi 1, 1, 32
161 ; CHECK-NEXT: ld 0, 16(1)
164 %m = tail call signext i32 @memcmp(ptr %X, ptr %Y, i64 2) nobuiltin
165 %c = icmp eq i32 %m, 0