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 3 4target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" 5target triple = "x86_64-pc-windows-msvc" 6 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 11 12; BFIHOIST-LABEL: define i32 @main 13; BFIHOIST: then: 14; BFIHOIST: %[[CONST1:.*]] = bitcast i64 9209618997431186100 to i64 15; BFIHOIST: %add = add i64 %call4, %[[CONST1]] 16; BFIHOIST: br label %endif 17; BFIHOIST: else: 18; BFIHOIST: %[[CONST2:.*]] = bitcast i64 9209618997431186100 to i64 19; BFIHOIST: %add6 = add i64 %call5, %[[CONST2]] 20; BFIHOIST: br label %endif 21 22; Function Attrs: norecurse 23define 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 28 29; <label>:1: ; preds = %0 30 %call2 = invoke i64 @fn(i64 %call) 31 to label %6 unwind label %catch.dispatch 32 33; <label>:2: ; preds = %0 34 %call3 = invoke i64 @fn(i64 %call1) 35 to label %6 unwind label %catch.dispatch 36 37catch.dispatch: ; preds = %2, %1 38 %z.0 = phi i64 [ %call, %1 ], [ %call1, %2 ] 39 %3 = catchswitch within none [label %4] unwind to caller 40 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 44 45then: 46 %call4 = tail call i64 @fn(i64 %z.0) [ "funclet"(token %5) ] 47 %add = add i64 %call4, 9209618997431186100 48 br label %endif 49 50else: 51 %call5 = tail call i64 @fn(i64 0) [ "funclet"(token %5) ] 52 %add6 = add i64 %call5, 9209618997431186100 53 br label %endif 54 55endif: 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 60 61; <label>:6: ; preds = %1, %2, %4 62 ret i32 0 63} 64 65declare i64 @fn(i64) local_unnamed_addr #1 66 67declare i32 @__CxxFrameHandler3(...) 68 69attributes #0 = { norecurse "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "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" } 70attributes #1 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "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" } 71