1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes=consthoist -consthoist-gep=1 -S | FileCheck %s
4 ; This is a reproducer for PR43903 where we hit an assertion:
5 ; opt: ../lib/Transforms/Scalar/ConstantHoisting.cpp:903: bool llvm::ConstantHoistingPass::emitBaseConstants(llvm::GlobalVariable *): Assertion `UsesNum == (ReBasesNum + NotRebasedNum) && "Not all uses are rebased"' failed.
7 target triple = "x86_64-unknown-linux-gnu"
9 @a = external global [2 x i16], align 1
13 ; CHECK-NEXT: for.cond:
14 ; CHECK-NEXT: br i1 undef, label [[FOR_BODY2:%.*]], label [[FOR_END4:%.*]]
16 ; CHECK-NEXT: br i1 undef, label [[LAND_RHS:%.*]], label [[LAND_END:%.*]]
18 ; CHECK-NEXT: unreachable
20 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule ptr undef, @a
21 ; CHECK-NEXT: unreachable
23 ; CHECK-NEXT: [[TMP0:%.*]] = load i16, ptr getelementptr inbounds ([2 x i16], ptr @a, i32 0, i32 1), align 1
24 ; CHECK-NEXT: br label [[FOR_COND3:%.*]]
26 ; CHECK-NEXT: [[TMP1:%.*]] = load i16, ptr @a, align 1
27 ; CHECK-NEXT: ret void
30 br i1 undef, label %for.body2, label %for.end4
32 for.body2: ; preds = %for.cond
33 br i1 undef, label %land.rhs, label %land.end
35 land.rhs: ; preds = %for.body2
38 land.end: ; preds = %for.body2
39 %cmp = icmp ule ptr undef, @a
42 for.cond3: ; preds = %for.cond3
43 %tmp0 = load i16, ptr getelementptr inbounds ([2 x i16], ptr @a, i32 0, i32 1), align 1
46 for.end4: ; preds = %for.cond
47 %tmp1 = load i16, ptr @a, align 1