[llvm-bugs] [Bug 52065] New: SelectInst that replaces Or/And is not handled in SimplifyCFG

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 4 05:05:22 PDT 2021


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

            Bug ID: 52065
           Summary: SelectInst that replaces Or/And is not handled in
                    SimplifyCFG
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Miscellaneous Instrumentation passes
          Assignee: unassignedbugs at nondot.org
          Reporter: elena.demikhovsky at intel.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 25323
  --> https://bugs.llvm.org/attachment.cgi?id=25323&action=edit
Before simpilfycfg, demonstrates Select/Or/And missing optimization

The basic block with "or" is optimized in simplifycfg:

  lor.lhs.false30:                                  ; preds = %lor.lhs.false
   %or.cond92 = or i1 %or.cond88, %cmp28
   br i1 %or.cond92, label %if.end, label %if.then

while the same block with "select" is not optimized:

  lor.lhs.false30:                                  ; preds = %lor.lhs.false
    %or.cond92 = select i1 %or.cond88, i1 true, i1 %cmp28
    br i1 %or.cond92, label %if.end, label %if.then

This diff maybe considered as a fix:
llvm/lib/Transforms/Utils/SimplifyCFG.cpp:

<   if (!Cond || (!isa<CmpInst>(Cond) && !isa<BinaryOperator>(Cond)) ||
---
>   auto isSelectAsBinaryOperator = [](Instruction *V) {
>     return match(V, m_Select(m_Value(), m_Value(), m_Zero())) ||
>            match(V, m_Select(m_Value(), m_One(), m_Value()));
>   };
>   if (!Cond ||
>       (!isa<CmpInst>(Cond) && !isa<BinaryOperator>(Cond) &&
>        !isSelectAsBinaryOperator(Cond)) ||

-- 
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/20211004/42fc3f49/attachment.html>


More information about the llvm-bugs mailing list