[llvm-bugs] [Bug 43313] New: [SimplifyCFG] switch transform drops "unpredictable" metadata

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 13 14:18:50 PDT 2019


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

            Bug ID: 43313
           Summary: [SimplifyCFG] switch transform drops "unpredictable"
                    metadata
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org

The branches in this IR are all marked unpredictable, but after 'opt
-simplifycfg', we have a switch instruction that is not marked unpredictable:
https://godbolt.org/z/neLzN3

define dso_local i64 @constant_time_lookup(i64 %0, i64* nocapture readonly %1)
local_unnamed_addr #0 {
  %3 = icmp eq i64 %0, 0
  br i1 %3, label %.thread, label %5, !unpredictable !2

.thread:                                          ; preds = %2
  %4 = load i64, i64* %1, align 8, !tbaa !3
  br label %.thread30

5:                                                ; preds = %2
  %6 = icmp eq i64 %0, 1
  br i1 %6, label %7, label %11, !unpredictable !2

7:                                                ; preds = %5
  %8 = getelementptr inbounds i64, i64* %1, i64 1
  %9 = load i64, i64* %8, align 8, !tbaa !3
  %10 = or i64 %9, 0
  br label %.thread30

11:                                               ; preds = %5
  %12 = icmp eq i64 %0, 2
  br i1 %12, label %13, label %17, !unpredictable !2

13:                                               ; preds = %11
  %14 = getelementptr inbounds i64, i64* %1, i64 2
  %15 = load i64, i64* %14, align 8, !tbaa !3
  %16 = or i64 %15, 0
  br label %.thread30

17:                                               ; preds = %11
  %18 = icmp eq i64 %0, 3
  br i1 %18, label %19, label %23, !unpredictable !2

19:                                               ; preds = %17
  %20 = getelementptr inbounds i64, i64* %1, i64 3
  %21 = load i64, i64* %20, align 8, !tbaa !3
  %22 = or i64 %21, 0
  br label %.thread30

23:                                               ; preds = %17
  %24 = icmp eq i64 %0, 4
  br i1 %24, label %25, label %29, !unpredictable !2

25:                                               ; preds = %23
  %26 = getelementptr inbounds i64, i64* %1, i64 4
  %27 = load i64, i64* %26, align 8, !tbaa !3
  %28 = or i64 %27, 0
  br label %.thread30

29:                                               ; preds = %23
  %30 = icmp eq i64 %0, 5
  br i1 %30, label %31, label %35, !unpredictable !2

31:                                               ; preds = %29
  %32 = getelementptr inbounds i64, i64* %1, i64 5
  %33 = load i64, i64* %32, align 8, !tbaa !3
  %34 = or i64 %33, 0
  br label %.thread30

35:                                               ; preds = %29
  %36 = icmp eq i64 %0, 6
  br i1 %36, label %37, label %41, !unpredictable !2

37:                                               ; preds = %35
  %38 = getelementptr inbounds i64, i64* %1, i64 6
  %39 = load i64, i64* %38, align 8, !tbaa !3
  %40 = or i64 %39, 0
  br label %.thread30

41:                                               ; preds = %35
  %42 = icmp eq i64 %0, 7
  br i1 %42, label %43, label %.thread30, !unpredictable !2

43:                                               ; preds = %41
  %44 = getelementptr inbounds i64, i64* %1, i64 7
  %45 = load i64, i64* %44, align 8, !tbaa !3
  %46 = or i64 %45, 0
  br label %.thread30

.thread30:                                        ; preds = %7, %.thread, %13,
%19, %25, %31, %37, %43, %41
  %.1.7 = phi i64 [ %46, %43 ], [ 0, %41 ], [ %40, %37 ], [ %34, %31 ], [ %28,
%25 ], [ %22, %19 ], [ %16, %13 ], [ %4, %.thread ], [ %10, %7 ]
  ret i64 %.1.7
}

attributes #0 = { norecurse nounwind readonly uwtable
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false"
"less-precise-fpmad"="false" "min-legal-vector-width"="0"
"no-frame-pointer-elim"="false" "no-infs-fp-math"="false"
"no-jump-tables"="false" "no-nans-fp-math"="false"
"no-signed-zeros-fp-math"="false" "no-trapping-math"="false"
"stack-protector-buffer-size"="8" "target-cpu"="x86-64"
"target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false"
"use-soft-float"="false" }

!llvm.module.flags = !{!0}
!llvm.ident = !{!1}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 8.0.0 (tags/RELEASE_800/final 356655)"}
!2 = !{!3, !3, i64 0}
!3 = !{!"long", !4, i64 0}
!4 = !{!"omnipotent char", !5, i64 0}
!5 = !{!"Simple C/C++ TBAA"}

-- 
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/20190913/55fbaeb1/attachment.html>


More information about the llvm-bugs mailing list