Arthur Eubanks | d0acd97 | 2020-08-05 13:49:00 -0700 | [diff] [blame] | 1 | ; RUN: opt < %s -loop-unswitch -enable-new-pm=0 -S | FileCheck %s |
| 2 | ; RUN: opt < %s -loop-unswitch -enable-new-pm=0 -enable-mssa-loop-dependency=true -verify-memoryssa -S | FileCheck %s |
Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 3 | |
| 4 | ; In cases where two address spaces do not have the same size pointer, the |
| 5 | ; input for the addrspacecast should not be used as a substitute for itself |
| 6 | ; when manipulating the pointer. |
| 7 | |
| 8 | target datalayout = "e-m:e-p:16:16-p1:32:16-i32:16-i64:16-n8:16" |
| 9 | |
| 10 | define void @foo() { |
| 11 | ; CHECK-LABEL: @foo |
| 12 | entry: |
| 13 | %arrayidx.i1 = getelementptr inbounds i16, i16* undef, i16 undef |
| 14 | %arrayidx.i = addrspacecast i16* %arrayidx.i1 to i16 addrspace(1)* |
| 15 | br i1 undef, label %for.body.i, label %bar.exit |
| 16 | |
| 17 | for.body.i: ; preds = %for.body.i, %entry |
| 18 | ; When we call makeLoopInvariant (i.e. trivial LICM) on this load, it |
| 19 | ; will try to find the base object to prove deferenceability. If we look |
| 20 | ; through the addrspacecast, we'll fail an assertion about bitwidths matching |
| 21 | ; CHECK-LABEL: for.body.i |
| 22 | ; CHECK: %0 = load i16, i16 addrspace(1)* %arrayidx.i, align 2 |
| 23 | %0 = load i16, i16 addrspace(1)* %arrayidx.i, align 2 |
| 24 | %cmp1.i = icmp eq i16 %0, 0 |
| 25 | br i1 %cmp1.i, label %bar.exit, label %for.body.i |
| 26 | |
| 27 | bar.exit: ; preds = %for.body.i, %entry |
| 28 | ret void |
| 29 | } |