1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -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: [[CONST1:%.*]] = bitcast i16* getelementptr inbounds ([2 x i16], [2 x i16]* @a, i32 0, i32 0) to i16*
21 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i16* undef, [[CONST1]]
22 ; CHECK-NEXT: unreachable
24 ; CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* getelementptr inbounds ([2 x i16], [2 x i16]* @a, i32 0, i32 1), align 1
25 ; CHECK-NEXT: br label [[FOR_COND3:%.*]]
27 ; CHECK-NEXT: [[CONST:%.*]] = bitcast i16* getelementptr inbounds ([2 x i16], [2 x i16]* @a, i32 0, i32 0) to i16*
28 ; CHECK-NEXT: [[TMP1:%.*]] = load i16, i16* [[CONST]], align 1
29 ; CHECK-NEXT: ret void
32 br i1 undef, label %for.body2, label %for.end4
34 for.body2: ; preds = %for.cond
35 br i1 undef, label %land.rhs, label %land.end
37 land.rhs: ; preds = %for.body2
40 land.end: ; preds = %for.body2
41 %cmp = icmp ule i16* undef, getelementptr inbounds ([2 x i16], [2 x i16]* @a, i32 0, i32 0)
44 for.cond3: ; preds = %for.cond3
45 %tmp0 = load i16, i16* getelementptr inbounds ([2 x i16], [2 x i16]* @a, i32 0, i32 1), align 1
48 for.end4: ; preds = %for.cond
49 %tmp1 = load i16, i16* getelementptr inbounds ([2 x i16], [2 x i16]* @a, i32 0, i32 0), align 1