[llvm-bugs] [Bug 34257] New: Loop unswitching stopped happening

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 21 07:18:05 PDT 2017


            Bug ID: 34257
           Summary: Loop unswitching stopped happening
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: aivchenk at gmail.com
                CC: llvm-bugs at lists.llvm.org

int foo(bool x, int a) {
  int s = a;
  int i = 0;
  while (i < 10000) {
    int y = x ? a : i;
    s += y;
  return s;
>clang++ foo.cpp -c -S -emit-llvm -o llvm_version.ll -O3

Before https://reviews.llvm.org/D35811 we used to nicely unswitch this loop:

define i32 @_Z12llvm_versionbi(i1 zeroext %x, i32 %a) local_unnamed_addr #0 {   
  %0 = mul i32 %a, 10001                                                        
  %1 = add i32 %a, 49995000                                                     
  %s.0.lcssa = select i1 %x, i32 %0, i32 %1                                     
  ret i32 %s.0.lcssa                                                            

I guess that degradation is expected, though, but, I'm not 100% sure

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/20170821/17bed168/attachment-0001.html>

More information about the llvm-bugs mailing list