diff options
Diffstat (limited to 'llvm/test/CodeGen/X86/materialize.ll')
-rw-r--r-- | llvm/test/CodeGen/X86/materialize.ll | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/materialize.ll b/llvm/test/CodeGen/X86/materialize.ll index 6e1264b4fd4..429d578fecc 100644 --- a/llvm/test/CodeGen/X86/materialize.ll +++ b/llvm/test/CodeGen/X86/materialize.ll @@ -30,6 +30,21 @@ entry: ; CHECK64-NEXT: retq } +define i32 @one32_pgso() !prof !14 { +entry: + ret i32 1 + +; CHECK32-LABEL: one32_pgso: +; CHECK32: xorl %eax, %eax +; CHECK32-NEXT: incl %eax +; CHECK32-NEXT: retl + +; FIXME: Figure out the best approach in 64-bit mode. +; CHECK64-LABEL: one32_pgso: +; CHECK64: movl $1, %eax +; CHECK64-NEXT: retq +} + define i32 @one32_minsize() minsize { entry: ret i32 1 @@ -107,6 +122,16 @@ entry: ; CHECK32-NEXT: retl } +define i32 @minus_one32_pgso() !prof !14 { +entry: + ret i32 -1 + +; CHECK32-LABEL: minus_one32_pgso: +; CHECK32: xorl %eax, %eax +; CHECK32-NEXT: decl %eax +; CHECK32-NEXT: retl +} + define i32 @minus_one32_minsize() minsize { entry: ret i32 -1 @@ -140,6 +165,28 @@ entry: ; CHECK32-NEXT: retl } +define i16 @one16_pgso() !prof !14 { +entry: + ret i16 1 + +; CHECK32-LABEL: one16_pgso: +; CHECK32: xorl %eax, %eax +; CHECK32-NEXT: incl %eax +; CHECK32-NEXT: # kill +; CHECK32-NEXT: retl +} + +define i16 @minus_one16_pgso() !prof !14 { +entry: + ret i16 -1 + +; CHECK32-LABEL: minus_one16_pgso: +; CHECK32: xorl %eax, %eax +; CHECK32-NEXT: decl %eax +; CHECK32-NEXT: # kill +; CHECK32-NEXT: retl +} + define i32 @minus_five32() minsize { entry: ret i32 -5 @@ -213,4 +260,72 @@ entry: ; CHECK32: retl } +define i32 @rematerialize_minus_one_pgso() !prof !14 { +entry: + ; Materialize -1 (thiscall forces it into %ecx). + tail call x86_thiscallcc void @f(i32 -1) + + ; Clobber all registers except %esp, leaving nowhere to store the -1 besides + ; spilling it to the stack. + tail call void asm sideeffect "", "~{eax},~{ebx},~{ecx},~{edx},~{edi},~{esi},~{ebp},~{dirflag},~{fpsr},~{flags}"() + + ; -1 should be re-materialized here instead of getting spilled above. + ret i32 -1 + +; CHECK32-LABEL: rematerialize_minus_one_pgso +; CHECK32: xorl %ecx, %ecx +; CHECK32-NEXT: decl %ecx +; CHECK32: calll +; CHECK32: xorl %eax, %eax +; CHECK32-NEXT: decl %eax +; CHECK32-NOT: %eax +; CHECK32: retl +} + +define i32 @rematerialize_minus_one_eflags_pgso(i32 %x) !prof !14 { +entry: + ; Materialize -1 (thiscall forces it into %ecx). + tail call x86_thiscallcc void @f(i32 -1) + + ; Clobber all registers except %esp, leaving nowhere to store the -1 besides + ; spilling it to the stack. + tail call void asm sideeffect "", "~{eax},~{ebx},~{ecx},~{edx},~{edi},~{esi},~{ebp},~{dirflag},~{fpsr},~{flags}"() + + ; Define eflags. + %a = icmp ne i32 %x, 123 + %b = zext i1 %a to i32 + ; Cause -1 to be rematerialized right in front of the cmov, which needs eflags. + ; It must therefore not use the xor-dec lowering. + %c = select i1 %a, i32 %b, i32 -1 + ret i32 %c + +; CHECK32-LABEL: rematerialize_minus_one_eflags_pgso +; CHECK32: xorl %ecx, %ecx +; CHECK32-NEXT: decl %ecx +; CHECK32: calll +; CHECK32: cmpl +; CHECK32: setne +; CHECK32-NOT: xorl +; CHECK32: movl $-1 +; CHECK32: cmov +; CHECK32: retl +} + declare x86_thiscallcc void @f(i32) + +!llvm.module.flags = !{!0} +!0 = !{i32 1, !"ProfileSummary", !1} +!1 = !{!2, !3, !4, !5, !6, !7, !8, !9} +!2 = !{!"ProfileFormat", !"InstrProf"} +!3 = !{!"TotalCount", i64 10000} +!4 = !{!"MaxCount", i64 10} +!5 = !{!"MaxInternalCount", i64 1} +!6 = !{!"MaxFunctionCount", i64 1000} +!7 = !{!"NumCounts", i64 3} +!8 = !{!"NumFunctions", i64 3} +!9 = !{!"DetailedSummary", !10} +!10 = !{!11, !12, !13} +!11 = !{i32 10000, i64 100, i32 1} +!12 = !{i32 999000, i64 100, i32 1} +!13 = !{i32 999999, i64 1, i32 2} +!14 = !{!"function_entry_count", i64 0} |