1 ; RUN: opt < %s -cost-model -analyze -cost-kind=code-size | \
2 ; RUN: FileCheck %s --check-prefixes=COMMON,CHECK-NO-SA
3 ; RUN: opt < %s -cost-model -analyze -cost-kind=code-size -mattr=+strict-align | \
4 ; RUN: FileCheck %s --check-prefixes=COMMON,CHECK-SA
6 target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
7 target triple = "thumbv7m-arm-unknown-eabi"
13 define void @memcpy_1(i8* %d, i8* %s) {
15 ; with/without strict-align:
20 ; COMMON: function 'memcpy_1'
21 ; CHECK-NO-SA-NEXT: cost of 2 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
22 ; CHECK-SA-NEXT: cost of 2 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
25 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %d, i8* align 1 %s, i32 1, i1 false)
29 define void @memcpy_2(i8* %d, i8* %s) {
43 ; COMMON: function 'memcpy_2'
44 ; CHECK-NO-SA-NEXT: cost of 2 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
45 ; CHECK-SA-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
48 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %d, i8* align 1 %s, i32 2, i1 false)
52 define void @memcpy_3(i8* %d, i8* %s) {
70 ; COMMON: function 'memcpy_3'
71 ; CHECK-NO-SA-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
72 ; CHECK-SA-NEXT: cost of 6 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
75 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %d, i8* align 1 %s, i32 3, i1 false)
79 define void @memcpy_4(i8* %d, i8* %s) {
97 ; COMMON: function 'memcpy_4'
98 ; CHECK-NO-SA-NEXT: cost of 2 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
99 ; CHECK-SA-NEXT: cost of 8 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
102 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %d, i8* align 1 %s, i32 4, i1 false)
106 define void @memcpy_8(i8* %d, i8* %s) {
122 ; COMMON: function 'memcpy_8'
123 ; COMMON-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
126 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %d, i8* align 1 %s, i32 8, i1 false)
130 define void @memcpy_16(i8* %d, i8* %s) {
150 ; COMMON: function 'memcpy_16'
151 ; CHECK-NO-SA-NEXT: cost of 8 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
152 ; CHECK-SA-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
155 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %d, i8* align 1 %s, i32 16, i1 false)
159 define void @memcpy_32(i8* %d, i8* %s, i32 %N) {
161 ; with/without strict-align:
166 ; COMMON: function 'memcpy_32'
167 ; COMMON-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
170 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %d, i8* align 1 %s, i32 32, i1 false)
174 define void @memcpy_N(i8* %d, i8* %s, i32 %N) {
176 ; with/without strict-align:
180 ; COMMON: function 'memcpy_N'
181 ; COMMON-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
184 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %d, i8* align 1 %s, i32 %N, i1 false)
192 define void @memcpy_1_al2(i8* %d, i8* %s) {
194 ; with/without strict-align:
199 ; COMMON: function 'memcpy_1_al2'
200 ; COMMON-NEXT: cost of 2 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
203 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %d, i8* align 2 %s, i32 1, i1 false)
207 define void @memcpy_2_al2(i8* %d, i8* %s) {
209 ; with/without strict-align:
214 ; COMMON: function 'memcpy_2_al2'
215 ; COMMON-NEXT: cost of 2 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
218 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %d, i8* align 2 %s, i32 2, i1 false)
222 define void @memcpy_3_al2(i8* %d, i8* %s) {
224 ; with/without strict-align:
231 ; COMMON: function 'memcpy_3_al2'
232 ; COMMON-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
235 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %d, i8* align 2 %s, i32 3, i1 false)
239 define void @memcpy_4_al2(i8* %d, i8* %s) {
253 ; COMMON: function 'memcpy_4_al2'
254 ; CHECK-NO-SA-NEXT: cost of 2 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
255 ; CHECK-SA-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
258 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %d, i8* align 2 %s, i32 4, i1 false)
262 define void @memcpy_8_al2(i8* %d, i8* %s) {
282 ; COMMON: function 'memcpy_8_al2'
283 ; CHECK-NO-SA-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
284 ; CHECK-SA-NEXT: cost of 8 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
287 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %d, i8* align 2 %s, i32 8, i1 false)
291 define void @memcpy_16_al2(i8* %d, i8* %s) {
309 ; COMMON: function 'memcpy_16_al2'
310 ; CHECK-NO-SA-NEXT: cost of 8 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
311 ; CHECK-SA-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
314 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %d, i8* align 2 %s, i32 16, i1 false)
318 define void @memcpy_32_al2(i8* %d, i8* %s, i32 %N) {
320 ; with/without strict-align:
325 ; COMMON: function 'memcpy_32_al2'
326 ; COMMON-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
329 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %d, i8* align 2 %s, i32 32, i1 false)
333 define void @memcpy_N_al2(i8* %d, i8* %s, i32 %N) {
335 ; with/without strict-align:
339 ; COMMON: function 'memcpy_N_al2'
340 ; COMMON-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
343 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %d, i8* align 2 %s, i32 %N, i1 false)
351 define void @memcpy_1_al4(i8* %d, i8* %s) {
353 ; with/without strict-align:
358 ; COMMON: function 'memcpy_1_al4'
359 ; COMMON-NEXT: cost of 2 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
362 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %d, i8* align 4 %s, i32 1, i1 false)
366 define void @memcpy_2_al4(i8* %d, i8* %s) {
368 ; with/without strict-align:
373 ; COMMON: function 'memcpy_2_al4'
374 ; COMMON-NEXT: cost of 2 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
377 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %d, i8* align 4 %s, i32 2, i1 false)
381 define void @memcpy_3_al4(i8* %d, i8* %s) {
383 ; with/without strict-align:
390 ; COMMON: function 'memcpy_3_al4'
391 ; COMMON-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
394 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %d, i8* align 4 %s, i32 3, i1 false)
398 define void @memcpy_4_al4(i8* %d, i8* %s) {
400 ; with/without strict-align:
405 ; COMMON: function 'memcpy_4_al4'
406 ; COMMON-NEXT: cost of 2 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
409 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %d, i8* align 4 %s, i32 4, i1 false)
413 define void @memcpy_8_al4(i8* %d, i8* %s) {
415 ; with/without strict-align:
420 ; COMMON: function 'memcpy_8_al4'
421 ; COMMON-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
424 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %d, i8* align 4 %s, i32 8, i1 false)
428 define void @memcpy_16_al4(i8* %d, i8* %s) {
430 ; with/without strict-align:
432 ; ldm.w r1, {r2, r3, r12}
434 ; stm.w r0, {r2, r3, r12}
437 ; COMMON: function 'memcpy_16_al4'
438 ; COMMON-NEXT: cost of 8 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
441 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %d, i8* align 4 %s, i32 16, i1 false)
445 define void @memcpy_32_al4(i8* %d, i8* %s, i32 %N) {
447 ; with/without strict-align:
449 ; ldm.w r1!, {r2, r3, r12, lr}
450 ; stm.w r0!, {r2, r3, r12, lr}
451 ; ldm.w r1, {r2, r3, r12, lr}
452 ; stm.w r0, {r2, r3, r12, lr}
454 ; COMMON: function 'memcpy_32_al4'
455 ; COMMON-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
458 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %d, i8* align 4 %s, i32 32, i1 false)
462 define void @memcpy_N_al4(i8* %d, i8* %s, i32 %N) {
464 ; with/without strict-align:
468 ; COMMON: function 'memcpy_N_al4'
469 ; COMMON-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
472 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %d, i8* align 4 %s, i32 %N, i1 false)
480 define void @memcpy_1_al14(i8* %d, i8* %s) {
482 ; with/without strict-align:
487 ; COMMON: function 'memcpy_1_al14'
488 ; COMMON-NEXT: cost of 2 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
491 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %d, i8* align 4 %s, i32 1, i1 false)
495 define void @memcpy_2_al14(i8* %d, i8* %s) {
509 ; COMMON: function 'memcpy_2_al14'
510 ; CHECK-NO-SA-NEXT: cost of 2 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
511 ; CHECK-SA-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
514 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %d, i8* align 4 %s, i32 2, i1 false)
518 define void @memcpy_3_al14(i8* %d, i8* %s) {
536 ; COMMON: function 'memcpy_3_al14'
537 ; CHECK-NO-SA-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
538 ; CHECK-SA-NEXT: cost of 6 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
541 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %d, i8* align 4 %s, i32 3, i1 false)
545 define void @memcpy_4_al14(i8* %d, i8* %s) {
563 ; COMMON: function 'memcpy_4_al14'
564 ; CHECK-NO-SA-NEXT: cost of 2 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
565 ; CHECK-SA-NEXT: cost of 8 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
568 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %d, i8* align 4 %s, i32 4, i1 false)
572 define void @memcpy_8_al14(i8* %d, i8* %s) {
588 ; COMMON: function 'memcpy_8_al14'
589 ; COMMON-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
592 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %d, i8* align 4 %s, i32 8, i1 false)
596 define void @memcpy_16_al14(i8* %d, i8* %s) {
614 ; COMMON: function 'memcpy_16_al14'
615 ; CHECK-NO-SA-NEXT: cost of 8 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
616 ; CHECK-SA-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
619 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %d, i8* align 4 %s, i32 16, i1 false)
623 define void @memcpy_32_al14(i8* %d, i8* %s) {
625 ; with/without strict-align:
630 ; COMMON: function 'memcpy_32_al14'
631 ; COMMON-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
634 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %d, i8* align 4 %s, i32 32, i1 false)
638 define void @memcpy_N_al14(i8* %d, i8* %s, i32 %N) {
640 ; with/without strict-align:
644 ; COMMON: function 'memcpy_N_al14'
645 ; COMMON-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
648 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %d, i8* align 4 %s, i32 %N, i1 false)
656 define void @memcpy_1_al41(i8* %d, i8* %s) {
658 ; with/without strict-align:
663 ; COMMON: function 'memcpy_1_al41'
664 ; COMMON-NEXT: cost of 4 for instruction: call void @llvm.memcpy.p0i8.p0i8.i32
667 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %d, i8* align 1 %s, i32 1, i1 false)
671 declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1) #1