diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-08-19 20:51:40 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-08-19 20:51:40 +0000 |
commit | f25fe647166375440a2945ca3393c1c54c3efe5c (patch) | |
tree | d32a450a896aa7da924c30509019c5095b3fda47 /llvm/test/CodeGen/X86/cmp.ll | |
parent | 7747ce226051791be0a03ec106d9502e3564c1af (diff) | |
download | bcm5719-llvm-f25fe647166375440a2945ca3393c1c54c3efe5c.tar.gz bcm5719-llvm-f25fe647166375440a2945ca3393c1c54c3efe5c.zip |
[X86] Emit more efficient >= comparisons against 0
We don't do a great job with >= 0 comparisons against zero when the
result is used as an i8.
Given something like:
void f(long long LL, bool *B) {
*B = LL >= 0;
}
We used to generate:
shrq $63, %rdi
xorb $1, %dil
movb %dil, (%rsi)
Now we generate:
testq %rdi, %rdi
setns (%rsi)
Differential Revision: http://reviews.llvm.org/D12136
llvm-svn: 245498
Diffstat (limited to 'llvm/test/CodeGen/X86/cmp.ll')
-rw-r--r-- | llvm/test/CodeGen/X86/cmp.ll | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/cmp.ll b/llvm/test/CodeGen/X86/cmp.ll index 584179aacbc..eb9a2901142 100644 --- a/llvm/test/CodeGen/X86/cmp.ll +++ b/llvm/test/CodeGen/X86/cmp.ll @@ -211,3 +211,47 @@ define zeroext i1 @test15(i32 %bf.load, i32 %n) { ; CHECK: shrl $16, %edi ; CHECK: cmpl %esi, %edi } + +define i8 @test16(i16 signext %L) { + %lshr = lshr i16 %L, 15 + %trunc = trunc i16 %lshr to i8 + %not = xor i8 %trunc, 1 + ret i8 %not + +; CHECK-LABEL: test16: +; CHECK: testw %di, %di +; CHECK: setns %al +} + +define i8 @test17(i32 %L) { + %lshr = lshr i32 %L, 31 + %trunc = trunc i32 %lshr to i8 + %not = xor i8 %trunc, 1 + ret i8 %not + +; CHECK-LABEL: test17: +; CHECK: testl %edi, %edi +; CHECK: setns %al +} + +define i8 @test18(i64 %L) { + %lshr = lshr i64 %L, 63 + %trunc = trunc i64 %lshr to i8 + %not = xor i8 %trunc, 1 + ret i8 %not + +; CHECK-LABEL: test18: +; CHECK: testq %rdi, %rdi +; CHECK: setns %al +} + +define zeroext i1 @test19(i32 %L) { + %lshr = lshr i32 %L, 31 + %trunc = trunc i32 %lshr to i1 + %not = xor i1 %trunc, 1 + ret i1 %not + +; CHECK-LABEL: test19: +; CHECK: testl %edi, %edi +; CHECK: setns %al +} |