diff options
author | Quentin Colombet <qcolombet@apple.com> | 2015-11-06 21:00:13 +0000 |
---|---|---|
committer | Quentin Colombet <qcolombet@apple.com> | 2015-11-06 21:00:13 +0000 |
commit | 9a8efc08d366526e1b4f964409b64b1068fb475c (patch) | |
tree | e04a1352b6f64b4bfb8b68a804c30ac6202df8b8 /llvm/test | |
parent | 9198c671e883fa579fa7b00cd86a2568d2cd3304 (diff) | |
download | bcm5719-llvm-9a8efc08d366526e1b4f964409b64b1068fb475c.tar.gz bcm5719-llvm-9a8efc08d366526e1b4f964409b64b1068fb475c.zip |
[ShrinkWrapping] Teach shrink-wrapping how to analyze RegMask.
Previously we were conservatively assuming that RegMask operands clobber
callee saved registers.
llvm-svn: 252341
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/CodeGen/X86/x86-shrink-wrapping.ll | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/x86-shrink-wrapping.ll b/llvm/test/CodeGen/X86/x86-shrink-wrapping.ll index 5d4e63b329f..52e094b5417 100644 --- a/llvm/test/CodeGen/X86/x86-shrink-wrapping.ll +++ b/llvm/test/CodeGen/X86/x86-shrink-wrapping.ll @@ -729,3 +729,62 @@ loop2b: ; preds = %loop1 end: ret void } + +; Check that we just don't bail out on RegMask. +; In this case, the RegMask does not touch a CSR so we are good to go! +; CHECK-LABEL: regmask: +; +; Compare the arguments and jump to exit. +; No prologue needed. +; ENABLE: cmpl %esi, %edi +; ENABLE-NEXT: jge [[EXIT_LABEL:LBB[0-9_]+]] +; +; Prologue code. +; (What we push does not matter. It should be some random sratch register.) +; CHECK: pushq +; +; Compare the arguments and jump to exit. +; After the prologue is set. +; DISABLE: cmpl %esi, %edi +; DISABLE-NEXT: jge [[EXIT_LABEL:LBB[0-9_]+]] +; +; CHECK: nop +; Set the first argument to zero. +; CHECK: xorl %edi, %edi +; Set the second argument to addr. +; CHECK-NEXT: movq %rdx, %rsi +; CHECK-NEXT: callq _doSomething +; CHECK-NEXT: popq +; CHECK-NEXT: retq +; +; CHECK: [[EXIT_LABEL]]: +; Set the first argument to 6. +; CHECK-NEXT: movl $6, %edi +; Set the second argument to addr. +; CHECK-NEXT: movq %rdx, %rsi +; +; Without shrink-wrapping, we need to restore the stack before +; making the tail call. +; Epilogue code. +; DISABLE-NEXT: popq +; +; CHECK-NEXT: jmp _doSomething +define i32 @regmask(i32 %a, i32 %b, i32* %addr) { + %tmp2 = icmp slt i32 %a, %b + br i1 %tmp2, label %true, label %false + +true: + ; Clobber a CSR so that we check something on the regmask + ; of the tail call. + tail call void asm sideeffect "nop", "~{ebx}"() + %tmp4 = call i32 @doSomething(i32 0, i32* %addr) + br label %end + +false: + %tmp5 = tail call i32 @doSomething(i32 6, i32* %addr) + br label %end + +end: + %tmp.0 = phi i32 [ %tmp4, %true ], [ %tmp5, %false ] + ret i32 %tmp.0 +} |