[llvm-bugs] [Bug 43014] New: Reuse ZF flags from xor; remove cmp

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 15 14:55:01 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=43014

            Bug ID: 43014
           Summary: Reuse ZF flags from xor; remove cmp
           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

#include <stdlib.h>
#include <stdio.h>
int p;

__attribute_noinline__ int foo(int x, int y) {
   p = x ^ y;
   if (x - y == 0) abort();
   return 0;
}

int main(int argc, char**argv) {
   foo(argc, atoi(argv[1]));
   printf("p = %d\n", p);
}

foo:                                    # @foo
        .cfi_startproc
# %bb.0:                                # %entry
        pushq   %rax
        .cfi_def_cfa_offset 16
        movl    %esi, %eax
        xorl    %edi, %eax
        movl    %eax, p(%rip)
        cmpl    %esi, %edi
        je      .LBB0_2

XOR sets ZF flag so.. I tried to remove cmp and compiled hand modified asm..

foo:                                    # @foo
        .cfi_startproc
# %bb.0:                                # %entry
        pushq   %rax
        .cfi_def_cfa_offset 16
        movl    %esi, %eax
        xorl    %edi, %eax
        movl    %eax, p(%rip)
        jz      .LBB0_2

and test case still  works as expected.

-- 
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/20190815/c685606c/attachment.html>


More information about the llvm-bugs mailing list