1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -loop-unswitch -S | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Worker; In cases where two address spaces do not have the same size pointer, the 4*9880d681SAndroid Build Coastguard Worker; input for the addrspacecast should not be used as a substitute for itself 5*9880d681SAndroid Build Coastguard Worker; when manipulating the pointer. 6*9880d681SAndroid Build Coastguard Worker 7*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:e-p:16:16-p1:32:16-i32:16-i64:16-n8:16" 8*9880d681SAndroid Build Coastguard Worker 9*9880d681SAndroid Build Coastguard Workerdefine void @foo() { 10*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @foo 11*9880d681SAndroid Build Coastguard Workerentry: 12*9880d681SAndroid Build Coastguard Worker %arrayidx.i1 = getelementptr inbounds i16, i16* undef, i16 undef 13*9880d681SAndroid Build Coastguard Worker %arrayidx.i = addrspacecast i16* %arrayidx.i1 to i16 addrspace(1)* 14*9880d681SAndroid Build Coastguard Worker br i1 undef, label %for.body.i, label %bar.exit 15*9880d681SAndroid Build Coastguard Worker 16*9880d681SAndroid Build Coastguard Workerfor.body.i: ; preds = %for.body.i, %entry 17*9880d681SAndroid Build Coastguard Worker; When we call makeLoopInvariant (i.e. trivial LICM) on this load, it 18*9880d681SAndroid Build Coastguard Worker; will try to find the base object to prove deferenceability. If we look 19*9880d681SAndroid Build Coastguard Worker; through the addrspacecast, we'll fail an assertion about bitwidths matching 20*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: for.body.i 21*9880d681SAndroid Build Coastguard Worker; CHECK: %0 = load i16, i16 addrspace(1)* %arrayidx.i, align 2 22*9880d681SAndroid Build Coastguard Worker %0 = load i16, i16 addrspace(1)* %arrayidx.i, align 2 23*9880d681SAndroid Build Coastguard Worker %cmp1.i = icmp eq i16 %0, 0 24*9880d681SAndroid Build Coastguard Worker br i1 %cmp1.i, label %bar.exit, label %for.body.i 25*9880d681SAndroid Build Coastguard Worker 26*9880d681SAndroid Build Coastguard Workerbar.exit: ; preds = %for.body.i, %entry 27*9880d681SAndroid Build Coastguard Worker ret void 28*9880d681SAndroid Build Coastguard Worker} 29