[llvm-bugs] [Bug 52077] New: Instcombine does not work after 'and'/'or' were replaced with 'select'

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 5 04:29:12 PDT 2021


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

            Bug ID: 52077
           Summary: Instcombine does not work after 'and'/'or' were
                    replaced with 'select'
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          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 25330
  --> https://bugs.llvm.org/attachment.cgi?id=25330&action=edit
The file demonstrates a missing optimization in instcombine

The code bellow is being optimized by instcombine if we put and/or instead of
'select':
lor.lhs.false:                                    ; preds = %for.body6
  %or.cond87.not = xor i1 %or.cond, true

  ;%or.cond88 = or i1 %or.cond87.not, %cmp16
  %or.cond88 = select i1 %or.cond87.not, i1 true, i1 %cmp16

  %or.cond88.not = xor i1 %or.cond88, true

  ;%or.cond89 = and i1 %or.cond88.not, %cmp28
  %or.cond89 = select i1 %or.cond88.not, i1 %cmp28, i1 false

  %or.cond89.not = xor i1 %or.cond89, true

  ;%or.cond92 = or i1 %or.cond88, %cmp28
  %or.cond92 = select i1 %or.cond88, i1 true, i1 %cmp28

  ;%or.cond93 = and i1 %or.cond89.not, %or.cond92
  %or.cond93 = select i1 %or.cond89.not, i1 %or.cond92, i1 false

There are also some changes were done in visitSelectInst()
if (match(TrueVal, m_One()) && impliesPoison(FalseVal, CondVal)) {
      // Change: A = select B, true, C --> A = or B, C
      return BinaryOperator::CreateOr(CondVal, FalseVal);
}
IsSafeToConvert() was replaced with impliesPoison()

-- 
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/20211005/733df774/attachment-0001.html>


More information about the llvm-bugs mailing list