1 ; RUN: opt -S -consthoist -consthoist-with-block-frequency=false < %s | FileCheck %s
2 ; RUN: opt -S -consthoist -consthoist-with-block-frequency=true < %s | FileCheck --check-prefix=BFIHOIST %s
4 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-pc-windows-msvc"
7 ; CHECK-LABEL: define i32 @main
8 ; CHECK: %tobool = icmp eq i32 %argc, 0
9 ; CHECK-NEXT: bitcast i64 9209618997431186100 to i64
10 ; CHECK-NEXT: br i1 %tobool
12 ; BFIHOIST-LABEL: define i32 @main
14 ; BFIHOIST: %[[CONST1:.*]] = bitcast i64 9209618997431186100 to i64
15 ; BFIHOIST: %add = add i64 %call4, %[[CONST1]]
16 ; BFIHOIST: br label %endif
18 ; BFIHOIST: %[[CONST2:.*]] = bitcast i64 9209618997431186100 to i64
19 ; BFIHOIST: %add6 = add i64 %call5, %[[CONST2]]
20 ; BFIHOIST: br label %endif
22 ; Function Attrs: norecurse
23 define i32 @main(i32 %argc, i8** nocapture readnone %argv) local_unnamed_addr #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
24 %call = tail call i64 @fn(i64 0)
25 %call1 = tail call i64 @fn(i64 1)
26 %tobool = icmp eq i32 %argc, 0
27 br i1 %tobool, label %2, label %1
29 ; <label>:1: ; preds = %0
30 %call2 = invoke i64 @fn(i64 %call)
31 to label %6 unwind label %catch.dispatch
33 ; <label>:2: ; preds = %0
34 %call3 = invoke i64 @fn(i64 %call1)
35 to label %6 unwind label %catch.dispatch
37 catch.dispatch: ; preds = %2, %1
38 %z.0 = phi i64 [ %call, %1 ], [ %call1, %2 ]
39 %3 = catchswitch within none [label %4] unwind to caller
41 ; <label>:4: ; preds = %catch.dispatch
42 %5 = catchpad within %3 [i8* null, i32 64, i8* null]
43 br i1 %tobool, label %then, label %else
46 %call4 = tail call i64 @fn(i64 %z.0) [ "funclet"(token %5) ]
47 %add = add i64 %call4, 9209618997431186100
51 %call5 = tail call i64 @fn(i64 0) [ "funclet"(token %5) ]
52 %add6 = add i64 %call5, 9209618997431186100
56 %v = phi i64 [ %add, %then ], [ %add6, %else ]
57 %call7 = tail call i64 @fn(i64 %v) [ "funclet"(token %5) ]
58 %call8 = tail call i64 @fn(i64 %call7) [ "funclet"(token %5) ]
59 catchret from %5 to label %6
61 ; <label>:6: ; preds = %1, %2, %4
65 declare i64 @fn(i64) local_unnamed_addr #1
67 declare i32 @__CxxFrameHandler3(...)
69 attributes #0 = { norecurse "disable-tail-calls"="false" "less-precise-fpmad"="false" "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" "stack-protector-buffer-size"="8" "target-features"="+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
70 attributes #1 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }