1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -mtriple aarch64-- -passes=consthoist -S | FileCheck %s
4 ; This used to trigger an assertion failure:
6 ; ../lib/Transforms/Scalar/ConstantHoisting.cpp:779: void llvm::ConstantHoistingPass::emitBaseConstants(llvm::Instruction *, llvm::Constant *, llvm::Type *, const llvm::consthoist::ConstantUser &): Assertion `CastInst->isCast() && "Expected an cast instruction!"' failed.
8 @c.a = external global i32, align 1
13 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i16 0, 0
14 ; CHECK-NEXT: br i1 undef, label [[LBL1_US:%.*]], label [[ENTRY_ENTRY_SPLIT_CRIT_EDGE:%.*]]
15 ; CHECK: entry.entry.split_crit_edge:
16 ; CHECK-NEXT: [[CONST:%.*]] = bitcast i32 1232131 to i32
17 ; CHECK-NEXT: br label [[LBL1:%.*]]
19 ; CHECK-NEXT: [[CONST1:%.*]] = bitcast i32 1232131 to i32
20 ; CHECK-NEXT: store i32 [[CONST1]], ptr @c.a, align 1
21 ; CHECK-NEXT: br label [[FOR_COND4:%.*]]
23 ; CHECK-NEXT: store i32 [[CONST]], ptr @c.a, align 1
24 ; CHECK-NEXT: br i1 undef, label [[IF_THEN:%.*]], label [[FOR_END12:%.*]]
26 ; CHECK-NEXT: br i1 undef, label [[LBL1]], label [[FOR_COND4]]
28 ; CHECK-NEXT: br label [[FOR_COND4]]
30 ; CHECK-NEXT: store i32 1232131, ptr undef, align 1
31 ; CHECK-NEXT: store i32 1232132, ptr undef, align 1
32 ; CHECK-NEXT: br label [[FOR_BODY9:%.*]]
34 ; CHECK-NEXT: ret void
37 %tobool = icmp ne i16 0, 0
38 br i1 undef, label %lbl1.us, label %entry.entry.split_crit_edge
40 entry.entry.split_crit_edge: ; preds = %entry
43 lbl1.us: ; preds = %entry
44 store i32 1232131, ptr @c.a, align 1
47 lbl1: ; preds = %if.then, %entry.entry.split_crit_edge
48 store i32 1232131, ptr @c.a, align 1
49 br i1 undef, label %if.then, label %for.end12
51 if.then: ; preds = %lbl1
52 br i1 undef, label %lbl1, label %for.cond4
54 for.cond4: ; preds = %for.cond4, %if.then, %lbl1.us
57 for.body9: ; preds = %for.body9
58 store i32 1232131, ptr undef, align 1
59 store i32 1232132, ptr undef, align 1
62 for.end12: ; preds = %lbl1