[LLVMbugs] [Bug 23851] New: metadata on branch not preserved with loop unswitch

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jun 15 13:09:39 PDT 2015


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

            Bug ID: 23851
           Summary: metadata on branch not preserved with loop unswitch
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: weimingz at codeaurora.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The metadata attached with the unswitched branch was not preserved.

test case:

;RUN: opt  -loop-unswitch -simplifycfg -S < %s | FileCheck %s

define i32 @foo(i32 %a, i32 %b) {
;CHECK-LABEL: foo
entry:
  br label %for.body.lr.ph

for.body.lr.ph:                                   ; preds = %entry
  %cmp.10 = icmp sgt i32 %b, 0
  br i1 %cmp.10, label %for.body, label %for.cond.cleanup

for.body:                                         ; preds = %for.inc,
%for.body.lr.ph
  %i.013 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
  %t2.012 = phi i32 [ 200, %for.body.lr.ph ], [ %t2.1, %for.inc ]
  %t1.011 = phi i32 [ 100, %for.body.lr.ph ], [ %t1.1, %for.inc ]
  %cmp1 = icmp eq i32 %a, 12345
  br i1 %cmp1, label %if.then, label %if.else, !prof !0
; CHECK: %cmp1 = icmp eq i32 %a, 12345
; CHECK-NEXT: br i1 %cmp1, label %if.then.us, label %if.else, !prof !0
if.then:                                          ; preds = %for.body
; CHECK: if.then.us:
; CHECK: %shr.us = ashr i32 %b, 1
; CHECK: tail call i32 @bar(i32 %shr.us)
; CHECK: add nuw nsw i32 %i.{{.*}}, 1
; CHECK: %exitcond.us = icmp eq i32 %inc.us, %b
; CHECK: br i1 %exitcond.us, label %for.cond.cleanup, label %if.then.us
  %shr = ashr i32 %b, 1
  %call = tail call i32 @bar(i32 %shr)
  %add = add nsw i32 %call, %t1.011
  br label %for.inc

if.else:                                          ; preds = %for.body
  %call2 = tail call i32 @bar(i32 %b)
  %mul = mul nsw i32 %call2, %t2.012
  br label %for.inc
; CHECK: if.else:
; CHECK: tail call i32 @bar(i32 %b)
; CHECK: %inc = add nuw nsw i32 %i.{{[0-9]+}}, 1
; CHECK: %exitcond = icmp eq i32 %inc, %b
; CHECK: br i1 %exitcond, label %for.cond.cleanup, label %if.else
for.inc:                                          ; preds = %if.then, %if.else
  %t1.1 = phi i32 [ %add, %if.then ], [ %t1.011, %if.else ]
  %t2.1 = phi i32 [ %t2.012, %if.then ], [ %mul, %if.else ]
  %inc = add nuw nsw i32 %i.013, 1
  %exitcond = icmp eq i32 %inc, %b
  br i1 %exitcond, label %for.cond.cleanup, label %for.body

for.cond.cleanup:                                 ; preds = %for.inc,
%for.body.lr.ph
  %t2.0.lcssa = phi i32 [ 200, %for.body.lr.ph ], [ %t2.1, %for.inc ]
  %t1.0.lcssa = phi i32 [ 100, %for.body.lr.ph ], [ %t1.1, %for.inc ]
  %add3 = add nsw i32 %t2.0.lcssa, %t1.0.lcssa
  ret i32 %add3
}
;CHECK: !0 = !{!"branch_weights", {{.*}}}
declare i32 @bar(i32)

!0 = !{!"branch_weights", i32 64, i32 4}

-- 
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/20150615/e132f1ae/attachment.html>


More information about the llvm-bugs mailing list