[llvm-bugs] [Bug 33583] New: Missing identical block merging

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jun 24 22:58:29 PDT 2017


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

            Bug ID: 33583
           Summary: Missing identical block merging
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: davide at freebsd.org
                CC: filcab at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, simon.f.whittaker at gmail.com

LLVM lowers the following (with -O3 -fno-vectorize -c)

extern void f4();

void function(int x) {
   if (x == 0) f4();
   else if (x == 1) f4();
   else if (x == 2) f4();
   else if (x == 3) f4();
   else if (x == 4) f4();
   else if (x == 5) f4();
   else if (x == 6) f4();
}

into a switch, but duplicates the destination block n times, 
i.e.

  switch i32 %0, label %9 [
    i32 0, label %2
    i32 1, label %3
    i32 2, label %4
    i32 3, label %5
    i32 4, label %6
    i32 5, label %7
    i32 6, label %8
  ]

; <label>:2:                                      ; preds = %1
  tail call void @f4()()
  br label %9

; <label>:3:                                      ; preds = %1
  tail call void @f4()()
  br label %9

; <label>:4:                                      ; preds = %1
  tail call void @f4()()
  br label %9

; <label>:5:                                      ; preds = %1
  tail call void @f4()()
  br label %9

; <label>:6:                                      ; preds = %1
  tail call void @f4()()
  br label %9

; <label>:7:                                      ; preds = %1
  tail call void @f4()()
  br label %9

We manage to recognize identical blocks in the backend and merge them,


but it seems we could do it already in the middle-end.

-- 
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/20170625/8035c0b2/attachment.html>


More information about the llvm-bugs mailing list