[llvm-bugs] [Bug 41113] New: swap select operands and reuse existing inverted condition

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Mar 17 07:14:04 PDT 2019


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

            Bug ID: 41113
           Summary: swap select operands and reuse existing inverted
                    condition
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org

I'm not sure if there's an existing pass that should have responsibility for
this transform:

define i1 @swapportunity(i8 %a, i8 %b, i8 %c, i8 %d, i8* %p) {
  %cmp1 = icmp ult i8 %a, %b
  %sel = select i1 %cmp1, i8 %c, i8 %d
  store i8 %sel, i8* %p
  %cmp2 = icmp uge i8 %a, %b ; this could also be a 'not' of cmp1
  ret i1 %cmp2
}

-->

define i1 @swapportunity(i8 %a, i8 %b, i8 %c, i8 %d, i8* %p) {
  %cmp2 = icmp uge i8 %a, %b
  %swap = select i1 %cmp2, i8 %d, i8 %c
  store i8 %swap, i8* %p
  ret i1 %cmp2
}

-------------------------------------------------------------------

It's not quite CSE or instcombine. There's precedence for a similar
analysis/transform in instcombine via "swapMayExposeCSEOpportunities()", but
that seems suspect to include there as this is not really a local/peephole
pattern-match.

-- 
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/20190317/41c3e860/attachment.html>


More information about the llvm-bugs mailing list