[llvm-bugs] [Bug 30327] New: [InstCombine] should sub C, (zext i1) be canonicalized to a select?

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 8 10:53:28 PDT 2016


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

            Bug ID: 30327
           Summary: [InstCombine] should sub C, (zext i1) be canonicalized
                    to a select?
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

These are logically equivalent:

unsigned sel(bool x) {
  if (x)
    return 54;
  else
    return 55;
}

unsigned add(bool x) {
  return 55 - x;
}

But the optimized IR is:

define i32 @sel(i1 zeroext %x) {
  %s = select i1 %x, i32 54, i32 55
  ret i32 %s
}

define i32 @add(i1 zeroext %x) {
  %conv = zext i1 %x to i32
  %sub = sub nsw i32 55, %conv
  ret i32 %sub
}

Which one is canonical?

-- 
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/20160908/3c168a35/attachment.html>


More information about the llvm-bugs mailing list