[llvm-bugs] [Bug 43597] New: Reuse flags from shift instruction -> avoid test instruction
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Oct 7 15:47:58 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43597
Bug ID: 43597
Summary: Reuse flags from shift instruction -> avoid test
instruction
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: david.bolvansky at gmail.com
CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
llvm-dev at redking.me.uk, spatel+llvm at rotateright.com
int foo (int a)
{
int b = 0;
while (a >>= 1)
b++;
return b;
}
foo:
mov eax, -1
.LBB0_1:
sar edi
add eax, 1
test edi, edi
jne .LBB0_1
ret
https://c9x.me/x86/html/file_module_x86_id_285.html
"The SF, ZF, and PF flags are set according to the result. If the count is 0,
the flags are not affected. For a non-zero count, the AF flag is undefined."
So 'test' could be eliminated here.
foo:
mov eax, -1
.LBB0_1:
add eax, 1
sar edi
jne .LBB0_1
ret
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191007/ac1c4b18/attachment.html>
More information about the llvm-bugs
mailing list