[llvm-bugs] [Bug 51577] New: Regression: Chain of branches/selects no longer simplified to chain of 'or'

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Aug 22 09:52:22 PDT 2021


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

            Bug ID: 51577
           Summary: Regression: Chain of branches/selects no longer
                    simplified to chain of 'or'
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Keywords: code-quality, quality-of-implementation, regression
          Severity: normal
          Priority: P
         Component: Transformation Utilities
          Assignee: unassignedbugs at nondot.org
          Reporter: nok.raven at gmail.com
                CC: llvm-bugs at lists.llvm.org

Something changed in the middle-end and a soup of icmp's, select's, and phi's
is now produced by the optimizer for these:

bool foo(bool& a, bool& b, bool& c, bool& d)
{
  bool r = false;
  if (a) r = true;
  if (b) r = true;
  if (c) r = true;
  if (d) r = true;
  return r;
}

bool bar(bool& a, bool& b, bool& c, bool& d)
{
  if (a) return true;
  if (b) return true;
  if (c) return true;
  if (d) return true;
  return false;
}
bool qaz(bool& a, bool& b, bool& c, bool& d)
{
  if (a) return true;
  if (b) return true;
  if (c) return true;
  return d;
}

bool zaq(bool& a, bool& b, bool& c, bool& d)
{
  bool r = false;
  /**/ if (a) r = true;
  else if (b) r = true;
  else if (c) r = true;
  else if (d) r = true;
  return r;
}


All functions are equivalent and should produce:

mov  al, byte ptr [rcx]
or   al, byte ptr [rdx]
or   al, byte ptr [rsi]
or   al, byte ptr [rdi]
ret

https://godbolt.org/z/re5KGeKPK

-- 
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/20210822/e54d5214/attachment.html>


More information about the llvm-bugs mailing list