[llvm-bugs] [Bug 47428] New: Opportunity to simplify conditions

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Sep 5 07:20:35 PDT 2020


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

            Bug ID: 47428
           Summary: Opportunity to simplify conditions
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            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

void bar (void);

void
foo (int a)
{
  if (a < 100)
    return;
  if (200 < a)
    return;

  if (a - 10 > 150)
    bar ();
}

Clang:
foo(int): # @foo(int)
  cmp edi, 161
  jl .LBB0_2
  add edi, -100
  cmp edi, 100
  ja .LBB0_2
  jmp bar() # TAILCALL
.LBB0_2:
  ret


GCC:
foo(int):
        sub     edi, 161
        cmp     edi, 39
        jbe     .L4
        ret
.L4:
        jmp     bar()



Maybe CE pass can simplify this code?

-- 
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/20200905/79223d01/attachment.html>


More information about the llvm-bugs mailing list