[llvm-bugs] [Bug 50199] New: Failed to remove cmp and merge identical blocks

via llvm-bugs llvm-bugs at lists.llvm.org
Sun May 2 05:32:13 PDT 2021


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

            Bug ID: 50199
           Summary: Failed to remove cmp and merge identical blocks
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org

union any {
    any(any& x) {
        if (x.st < 4) {
            x.st = 0;
        } else {
            x.ex = nullptr;
        }
    }
    long st;
    void* ex;
};
void f(any* b) {
   (any(*b));
}




%union.any = type { i64 }

define dso_local void @_Z1fP3any(%union.any* nocapture %0) local_unnamed_addr
#0 {
  %2 = getelementptr inbounds %union.any, %union.any* %0, i64 0, i32 0
  %3 = load i64, i64* %2, align 8, !tbaa !3
  %4 = icmp slt i64 %3, 4
  br i1 %4, label %5, label %6

5:                                                ; preds = %1
  store i64 0, i64* %2, align 8, !tbaa !3
  br label %8

6:                                                ; preds = %1
  %7 = bitcast %union.any* %0 to i8**
  store i8* null, i8** %7, align 8, !tbaa !3
  br label %8

8:                                                ; preds = %5, %6
  ret void
}


f(any*):                              # @f(any*)
        cmp     qword ptr [rdi], 3
        mov     qword ptr [rdi], 0
        ret


https://godbolt.org/z/b17vfY9eK


It seems that backend already does a good job and merges the blocks. 

Middle-end should be able to simplify this even futher - remove condition,
merge blocks & unify stores, ..

-- 
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/20210502/1307ce03/attachment-0001.html>


More information about the llvm-bugs mailing list