1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s 3 4; Check that multiple instances of 64-bit constants encodable as 5; 32-bit immediates are merged for code size savings. 6 7; Immediates with multiple users should not be pulled into instructions when 8; optimizing for code size (but 8-bit immediates are exceptions). 9 10define i1 @imm_multiple_users(i64 %a, i64* %b) optsize { 11; CHECK-LABEL: imm_multiple_users: 12; CHECK: # %bb.0: 13; CHECK-NEXT: movq $-1, (%rsi) 14; CHECK-NEXT: cmpq $-1, %rdi 15; CHECK-NEXT: sete %al 16; CHECK-NEXT: retq 17 store i64 -1, i64* %b, align 8 18 %cmp = icmp eq i64 %a, -1 19 ret i1 %cmp 20} 21 22define i1 @imm_multiple_users_pgso(i64 %a, i64* %b) !prof !14 { 23; CHECK-LABEL: imm_multiple_users_pgso: 24; CHECK: # %bb.0: 25; CHECK-NEXT: movq $-1, (%rsi) 26; CHECK-NEXT: cmpq $-1, %rdi 27; CHECK-NEXT: sete %al 28; CHECK-NEXT: retq 29 store i64 -1, i64* %b, align 8 30 %cmp = icmp eq i64 %a, -1 31 ret i1 %cmp 32} 33 34declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1) 35 36; Inlined memsets requiring multiple same-sized stores should be lowered using 37; the register, rather than immediate, form of stores when optimizing for 38; code size. 39define void @memset_zero(i8* noalias nocapture %D) optsize { 40; CHECK-LABEL: memset_zero: 41; CHECK: # %bb.0: 42; CHECK-NEXT: xorl %eax, %eax 43; CHECK-NEXT: movq %rax, 7(%rdi) 44; CHECK-NEXT: movq %rax, (%rdi) 45; CHECK-NEXT: retq 46 tail call void @llvm.memset.p0i8.i64(i8* %D, i8 0, i64 15, i1 false) 47 ret void 48} 49 50define void @memset_zero_pgso(i8* noalias nocapture %D) !prof !14 { 51; CHECK-LABEL: memset_zero_pgso: 52; CHECK: # %bb.0: 53; CHECK-NEXT: xorl %eax, %eax 54; CHECK-NEXT: movq %rax, 7(%rdi) 55; CHECK-NEXT: movq %rax, (%rdi) 56; CHECK-NEXT: retq 57 tail call void @llvm.memset.p0i8.i64(i8* %D, i8 0, i64 15, i1 false) 58 ret void 59} 60 61!llvm.module.flags = !{!0} 62!0 = !{i32 1, !"ProfileSummary", !1} 63!1 = !{!2, !3, !4, !5, !6, !7, !8, !9} 64!2 = !{!"ProfileFormat", !"InstrProf"} 65!3 = !{!"TotalCount", i64 10000} 66!4 = !{!"MaxCount", i64 10} 67!5 = !{!"MaxInternalCount", i64 1} 68!6 = !{!"MaxFunctionCount", i64 1000} 69!7 = !{!"NumCounts", i64 3} 70!8 = !{!"NumFunctions", i64 3} 71!9 = !{!"DetailedSummary", !10} 72!10 = !{!11, !12, !13} 73!11 = !{i32 10000, i64 100, i32 1} 74!12 = !{i32 999000, i64 100, i32 1} 75!13 = !{i32 999999, i64 1, i32 2} 76!14 = !{!"function_entry_count", i64 0} 77