29 lines · plain
1; RUN: opt < %s -passes="loop-mssa(simple-loop-unswitch)" -verify-memoryssa -S | FileCheck %s2 3; In cases where two address spaces do not have the same size pointer, the4; input for the addrspacecast should not be used as a substitute for itself5; when manipulating the pointer.6 7target datalayout = "e-m:e-p:16:16-p1:32:16-i32:16-i64:16-n8:16"8 9define void @foo(i1 %arg) {10; CHECK-LABEL: @foo11entry:12 %arrayidx.i1 = getelementptr inbounds i16, ptr undef, i16 undef13 %arrayidx.i = addrspacecast ptr %arrayidx.i1 to ptr addrspace(1)14 br i1 %arg, label %for.body.i, label %bar.exit15 16for.body.i: ; preds = %for.body.i, %entry17; When we call makeLoopInvariant (i.e. trivial LICM) on this load, it18; will try to find the base object to prove deferenceability. If we look19; through the addrspacecast, we'll fail an assertion about bitwidths matching20; CHECK-LABEL: for.body.i21; CHECK: %0 = load i16, ptr addrspace(1) %arrayidx.i, align 222 %0 = load i16, ptr addrspace(1) %arrayidx.i, align 223 %cmp1.i = icmp eq i16 %0, 024 br i1 %cmp1.i, label %bar.exit, label %for.body.i25 26bar.exit: ; preds = %for.body.i, %entry27 ret void28}29