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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to