[llvm-bugs] [Bug 47730] New: [11 regression] No elimination of conditional addition of zero

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 5 07:09:32 PDT 2020


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

            Bug ID: 47730
           Summary: [11 regression] No elimination of conditional addition
                    of zero
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org

struct vector {
    int *data;
    unsigned long size;
};


int *vector_end_zero_add(struct vector *vec)
{
    if (vec->size == 0)
        return vec->data;
    return vec->data + vec->size;
}




Trunk:
vector_end_zero_add(vector*): # @vector_end_zero_add(vector*)
  mov rcx, qword ptr [rdi]
  mov rax, qword ptr [rdi + 8]
  test rax, rax
  lea rax, [rcx + 4*rax]
  cmove rax, rcx
  ret


10.0.1:
vector_end_zero_add(vector*): # @vector_end_zero_add(vector*)
  mov rax, qword ptr [rdi + 8]
  shl rax, 2
  add rax, qword ptr [rdi]
  ret


What is really weird, with "unsigned size;", even Clang 10.0.1 cannot optimize
it.

Current codegen:
https://godbolt.org/z/1Pr43K

-- 
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/20201005/fbddbb96/attachment.html>


More information about the llvm-bugs mailing list