1 ; RUN: llc -o - -mtriple=powerpc64le-unknown-gnu-linux -stop-after codegenprepare %s | FileCheck %s
2 ; RUN: llc -o - -mtriple=powerpc64-unknown-gnu-linux -stop-after codegenprepare %s | FileCheck %s --check-prefix=CHECK-BE
4 define signext i32 @test1(ptr nocapture readonly %buffer1, ptr nocapture readonly %buffer2) {
7 ; CHECK-LABEL: res_block:{{.*}}
8 ; CHECK: [[ICMP2:%[0-9]+]] = icmp ult i64
9 ; CHECK-NEXT: [[SELECT:%[0-9]+]] = select i1 [[ICMP2]], i32 -1, i32 1
10 ; CHECK-NEXT: br label %endblock
12 ; CHECK-LABEL: loadbb:{{.*}}
13 ; CHECK: [[LOAD1:%[0-9]+]] = load i64, ptr
14 ; CHECK-NEXT: [[LOAD2:%[0-9]+]] = load i64, ptr
15 ; CHECK-NEXT: [[BSWAP1:%[0-9]+]] = call i64 @llvm.bswap.i64(i64 [[LOAD1]])
16 ; CHECK-NEXT: [[BSWAP2:%[0-9]+]] = call i64 @llvm.bswap.i64(i64 [[LOAD2]])
17 ; CHECK-NEXT: [[ICMP:%[0-9]+]] = icmp eq i64 [[BSWAP1]], [[BSWAP2]]
18 ; CHECK-NEXT: br i1 [[ICMP]], label %loadbb1, label %res_block
20 ; CHECK-LABEL: loadbb1:{{.*}}
21 ; CHECK-NEXT: [[GEP1:%[0-9]+]] = getelementptr i8, ptr {{.*}}, i64 8
22 ; CHECK-NEXT: [[GEP2:%[0-9]+]] = getelementptr i8, ptr {{.*}}, i64 8
23 ; CHECK-NEXT: [[LOAD1:%[0-9]+]] = load i64, ptr [[GEP1]]
24 ; CHECK-NEXT: [[LOAD2:%[0-9]+]] = load i64, ptr [[GEP2]]
25 ; CHECK-NEXT: [[BSWAP1:%[0-9]+]] = call i64 @llvm.bswap.i64(i64 [[LOAD1]])
26 ; CHECK-NEXT: [[BSWAP2:%[0-9]+]] = call i64 @llvm.bswap.i64(i64 [[LOAD2]])
27 ; CHECK-NEXT: [[ICMP:%[0-9]+]] = icmp eq i64 [[BSWAP1]], [[BSWAP2]]
28 ; CHECK-NEXT: br i1 [[ICMP]], label %endblock, label %res_block
30 ; CHECK-BE-LABEL: @test1(
31 ; CHECK-BE-LABEL: res_block:{{.*}}
32 ; CHECK-BE: [[ICMP2:%[0-9]+]] = icmp ult i64
33 ; CHECK-BE-NEXT: [[SELECT:%[0-9]+]] = select i1 [[ICMP2]], i32 -1, i32 1
34 ; CHECK-BE-NEXT: br label %endblock
36 ; CHECK-BE-LABEL: loadbb:{{.*}}
37 ; CHECK-BE: [[LOAD1:%[0-9]+]] = load i64, ptr
38 ; CHECK-BE-NEXT: [[LOAD2:%[0-9]+]] = load i64, ptr
39 ; CHECK-BE-NEXT: [[ICMP:%[0-9]+]] = icmp eq i64 [[LOAD1]], [[LOAD2]]
40 ; CHECK-BE-NEXT: br i1 [[ICMP]], label %loadbb1, label %res_block
42 ; CHECK-BE-LABEL: loadbb1:{{.*}}
43 ; CHECK-BE-NEXT: [[GEP1:%[0-9]+]] = getelementptr i8, ptr {{.*}}, i64 8
44 ; CHECK-BE-NEXT: [[GEP2:%[0-9]+]] = getelementptr i8, ptr {{.*}}, i64 8
45 ; CHECK-BE-NEXT: [[LOAD1:%[0-9]+]] = load i64, ptr [[GEP1]]
46 ; CHECK-BE-NEXT: [[LOAD2:%[0-9]+]] = load i64, ptr [[GEP2]]
47 ; CHECK-BE-NEXT: [[ICMP:%[0-9]+]] = icmp eq i64 [[LOAD1]], [[LOAD2]]
48 ; CHECK-BE-NEXT: br i1 [[ICMP]], label %endblock, label %res_block
50 %call = tail call signext i32 @memcmp(ptr %buffer1, ptr %buffer2, i64 16)
54 declare signext i32 @memcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #1
56 define signext i32 @test2(ptr nocapture readonly %buffer1, ptr nocapture readonly %buffer2) {
57 ; CHECK-LABEL: @test2(
58 ; CHECK: [[LOAD1:%[0-9]+]] = load i32, ptr
59 ; CHECK-NEXT: [[LOAD2:%[0-9]+]] = load i32, ptr
60 ; CHECK-NEXT: [[BSWAP1:%[0-9]+]] = call i32 @llvm.bswap.i32(i32 [[LOAD1]])
61 ; CHECK-NEXT: [[BSWAP2:%[0-9]+]] = call i32 @llvm.bswap.i32(i32 [[LOAD2]])
62 ; CHECK-NEXT: [[CMP1:%[0-9]+]] = icmp ugt i32 [[BSWAP1]], [[BSWAP2]]
63 ; CHECK-NEXT: [[CMP2:%[0-9]+]] = icmp ult i32 [[BSWAP1]], [[BSWAP2]]
64 ; CHECK-NEXT: [[Z1:%[0-9]+]] = zext i1 [[CMP1]] to i32
65 ; CHECK-NEXT: [[Z2:%[0-9]+]] = zext i1 [[CMP2]] to i32
66 ; CHECK-NEXT: [[SUB:%[0-9]+]] = sub i32 [[Z1]], [[Z2]]
67 ; CHECK-NEXT: ret i32 [[SUB]]
69 ; CHECK-BE-LABEL: @test2(
70 ; CHECK-BE: [[LOAD1:%[0-9]+]] = load i32, ptr
71 ; CHECK-BE-NEXT: [[LOAD2:%[0-9]+]] = load i32, ptr
72 ; CHECK-BE-NEXT: [[CMP1:%[0-9]+]] = icmp ugt i32 [[LOAD1]], [[LOAD2]]
73 ; CHECK-BE-NEXT: [[CMP2:%[0-9]+]] = icmp ult i32 [[LOAD1]], [[LOAD2]]
74 ; CHECK-BE-NEXT: [[Z1:%[0-9]+]] = zext i1 [[CMP1]] to i32
75 ; CHECK-BE-NEXT: [[Z2:%[0-9]+]] = zext i1 [[CMP2]] to i32
76 ; CHECK-BE-NEXT: [[SUB:%[0-9]+]] = sub i32 [[Z1]], [[Z2]]
77 ; CHECK-BE-NEXT: ret i32 [[SUB]]
80 %call = tail call signext i32 @memcmp(ptr %buffer1, ptr %buffer2, i64 4)
84 define signext i32 @test3(ptr nocapture readonly %buffer1, ptr nocapture readonly %buffer2) {
85 ; CHECK-LABEL: res_block:{{.*}}
86 ; CHECK: [[ICMP2:%[0-9]+]] = icmp ult i64
87 ; CHECK-NEXT: [[SELECT:%[0-9]+]] = select i1 [[ICMP2]], i32 -1, i32 1
88 ; CHECK-NEXT: br label %endblock
90 ; CHECK-LABEL: loadbb:{{.*}}
91 ; CHECK: [[LOAD1:%[0-9]+]] = load i64, ptr
92 ; CHECK-NEXT: [[LOAD2:%[0-9]+]] = load i64, ptr
93 ; CHECK-NEXT: [[BSWAP1:%[0-9]+]] = call i64 @llvm.bswap.i64(i64 [[LOAD1]])
94 ; CHECK-NEXT: [[BSWAP2:%[0-9]+]] = call i64 @llvm.bswap.i64(i64 [[LOAD2]])
95 ; CHECK-NEXT: [[ICMP:%[0-9]+]] = icmp eq i64 [[BSWAP1]], [[BSWAP2]]
96 ; CHECK-NEXT: br i1 [[ICMP]], label %loadbb1, label %res_block
98 ; CHECK-LABEL: loadbb1:{{.*}}
99 ; CHECK: [[LOAD1:%[0-9]+]] = load i32, ptr
100 ; CHECK-NEXT: [[LOAD2:%[0-9]+]] = load i32, ptr
101 ; CHECK-NEXT: [[BSWAP1:%[0-9]+]] = call i32 @llvm.bswap.i32(i32 [[LOAD1]])
102 ; CHECK-NEXT: [[BSWAP2:%[0-9]+]] = call i32 @llvm.bswap.i32(i32 [[LOAD2]])
103 ; CHECK-NEXT: [[ZEXT1:%[0-9]+]] = zext i32 [[BSWAP1]] to i64
104 ; CHECK-NEXT: [[ZEXT2:%[0-9]+]] = zext i32 [[BSWAP2]] to i64
105 ; CHECK-NEXT: [[ICMP:%[0-9]+]] = icmp eq i64 [[ZEXT1]], [[ZEXT2]]
106 ; CHECK-NEXT: br i1 [[ICMP]], label %loadbb2, label %res_block
108 ; CHECK-LABEL: loadbb2:{{.*}}
109 ; CHECK: [[LOAD1:%[0-9]+]] = load i16, ptr
110 ; CHECK-NEXT: [[LOAD2:%[0-9]+]] = load i16, ptr
111 ; CHECK-NEXT: [[BSWAP1:%[0-9]+]] = call i16 @llvm.bswap.i16(i16 [[LOAD1]])
112 ; CHECK-NEXT: [[BSWAP2:%[0-9]+]] = call i16 @llvm.bswap.i16(i16 [[LOAD2]])
113 ; CHECK-NEXT: [[ZEXT1:%[0-9]+]] = zext i16 [[BSWAP1]] to i64
114 ; CHECK-NEXT: [[ZEXT2:%[0-9]+]] = zext i16 [[BSWAP2]] to i64
115 ; CHECK-NEXT: [[ICMP:%[0-9]+]] = icmp eq i64 [[ZEXT1]], [[ZEXT2]]
116 ; CHECK-NEXT: br i1 [[ICMP]], label %loadbb3, label %res_block
118 ; CHECK-LABEL: loadbb3:{{.*}}
119 ; CHECK: [[LOAD1:%[0-9]+]] = load i8, ptr
120 ; CHECK-NEXT: [[LOAD2:%[0-9]+]] = load i8, ptr
121 ; CHECK-NEXT: [[ZEXT1:%[0-9]+]] = zext i8 [[LOAD1]] to i32
122 ; CHECK-NEXT: [[ZEXT2:%[0-9]+]] = zext i8 [[LOAD2]] to i32
123 ; CHECK-NEXT: [[SUB:%[0-9]+]] = sub i32 [[ZEXT1]], [[ZEXT2]]
124 ; CHECK-NEXT: br label %endblock
126 ; CHECK-BE-LABEL: res_block:{{.*}}
127 ; CHECK-BE: [[ICMP2:%[0-9]+]] = icmp ult i64
128 ; CHECK-BE-NEXT: [[SELECT:%[0-9]+]] = select i1 [[ICMP2]], i32 -1, i32 1
129 ; CHECK-BE-NEXT: br label %endblock
131 ; CHECK-BE-LABEL: loadbb:{{.*}}
132 ; CHECK-BE: [[LOAD1:%[0-9]+]] = load i64, ptr
133 ; CHECK-BE-NEXT: [[LOAD2:%[0-9]+]] = load i64, ptr
134 ; CHECK-BE-NEXT: [[ICMP:%[0-9]+]] = icmp eq i64 [[LOAD1]], [[LOAD2]]
135 ; CHECK-BE-NEXT: br i1 [[ICMP]], label %loadbb1, label %res_block
137 ; CHECK-BE: [[LOAD1:%[0-9]+]] = load i32, ptr
138 ; CHECK-BE-NEXT: [[LOAD2:%[0-9]+]] = load i32, ptr
139 ; CHECK-BE-NEXT: [[ZEXT1:%[0-9]+]] = zext i32 [[LOAD1]] to i64
140 ; CHECK-BE-NEXT: [[ZEXT2:%[0-9]+]] = zext i32 [[LOAD2]] to i64
141 ; CHECK-BE-NEXT: [[ICMP:%[0-9]+]] = icmp eq i64 [[ZEXT1]], [[ZEXT2]]
142 ; CHECK-BE-NEXT: br i1 [[ICMP]], label %loadbb2, label %res_block
144 ; CHECK-BE: [[LOAD1:%[0-9]+]] = load i16, ptr
145 ; CHECK-BE-NEXT: [[LOAD2:%[0-9]+]] = load i16, ptr
146 ; CHECK-BE-NEXT: [[ZEXT1:%[0-9]+]] = zext i16 [[LOAD1]] to i64
147 ; CHECK-BE-NEXT: [[ZEXT2:%[0-9]+]] = zext i16 [[LOAD2]] to i64
148 ; CHECK-BE-NEXT: [[ICMP:%[0-9]+]] = icmp eq i64 [[ZEXT1]], [[ZEXT2]]
149 ; CHECK-BE-NEXT: br i1 [[ICMP]], label %loadbb3, label %res_block
151 ; CHECK-BE: [[LOAD1:%[0-9]+]] = load i8, ptr
152 ; CHECK-BE-NEXT: [[LOAD2:%[0-9]+]] = load i8, ptr
153 ; CHECK-BE-NEXT: [[ZEXT1:%[0-9]+]] = zext i8 [[LOAD1]] to i32
154 ; CHECK-BE-NEXT: [[ZEXT2:%[0-9]+]] = zext i8 [[LOAD2]] to i32
155 ; CHECK-BE-NEXT: [[SUB:%[0-9]+]] = sub i32 [[ZEXT1]], [[ZEXT2]]
156 ; CHECK-BE-NEXT: br label %endblock
159 %call = tail call signext i32 @memcmp(ptr %buffer1, ptr %buffer2, i64 15)
162 ; CHECK: call = tail call signext i32 @memcmp
163 ; CHECK-BE: call = tail call signext i32 @memcmp
164 define signext i32 @test4(ptr nocapture readonly %buffer1, ptr nocapture readonly %buffer2) {
167 %call = tail call signext i32 @memcmp(ptr %buffer1, ptr %buffer2, i64 65)
171 define signext i32 @test5(ptr nocapture readonly %buffer1, ptr nocapture readonly %buffer2, i32 signext %SIZE) {
172 ; CHECK: call = tail call signext i32 @memcmp
173 ; CHECK-BE: call = tail call signext i32 @memcmp
175 %conv = sext i32 %SIZE to i64
176 %call = tail call signext i32 @memcmp(ptr %buffer1, ptr %buffer2, i64 %conv)