1 ; RUN: opt -gvn -S < %s | FileCheck %s
2 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-p100:128:64:64-p101:128:64:64"
3 target triple = "x86_64-unknown-linux-gnu"
5 %ArrayImpl = type { i64, i64 addrspace(100)*, [1 x i64], [1 x i64], [1 x i64], i64, i64, double addrspace(100)*, double addrspace(100)*, i8, i64 }
6 %_array = type { i64, %ArrayImpl addrspace(100)*, i8 }
8 define void @test(i64 %n_chpl) {
10 ; First section is some code
11 %0 = getelementptr inbounds %_array, %_array* null, i32 0, i32 1
12 %1 = load %ArrayImpl addrspace(100)*, %ArrayImpl addrspace(100)** %0
13 %2 = getelementptr inbounds %ArrayImpl, %ArrayImpl addrspace(100)* %1, i32 0, i32 8
14 %3 = load double addrspace(100)*, double addrspace(100)* addrspace(100)* %2
15 %4 = getelementptr inbounds double, double addrspace(100)* %3, i64 -1
16 ; Second section is that code repeated
17 %x0 = getelementptr inbounds %_array, %_array* null, i32 0, i32 1
18 %x1 = load %ArrayImpl addrspace(100)*, %ArrayImpl addrspace(100)** %x0
19 %x2 = getelementptr inbounds %ArrayImpl, %ArrayImpl addrspace(100)* %x1, i32 0, i32 8
20 %x3 = load double addrspace(100)*, double addrspace(100)* addrspace(100)* %x2
21 %x4 = getelementptr inbounds double, double addrspace(100)* %x3, i64 -1
22 ; These two stores refer to the same memory location
23 ; Even so, they are expected to remain separate stores here
24 store double 0.000000e+00, double addrspace(100)* %4
25 store double 0.000000e+00, double addrspace(100)* %x4
26 ; Third section is the repeated code again, with a later store
27 ; This third section is necessary to trigger the crash
28 %y1 = load %ArrayImpl addrspace(100)*, %ArrayImpl addrspace(100)** %0
29 %y2 = getelementptr inbounds %ArrayImpl, %ArrayImpl addrspace(100)* %y1, i32 0, i32 8
30 %y3 = load double addrspace(100)*, double addrspace(100)* addrspace(100)* %y2
31 %y4 = getelementptr inbounds double, double addrspace(100)* %y3, i64 -1
32 store double 0.000000e+00, double addrspace(100)* %y4
34 ; CHECK-LABEL: define void @test
35 ; CHECK: getelementptr inbounds double, double addrspace(100)* {{%.*}}, i64 -1
36 ; CHECK-NEXT: store double 0.000000e+00, double addrspace(100)* [[DST:%.*]]
37 ; CHECK-NEXT: store double 0.000000e+00, double addrspace(100)* [[DST]]
39 ; CHECK: getelementptr inbounds %ArrayImpl, %ArrayImpl addrspace(100)*
41 ; CHECK: getelementptr inbounds double, double addrspace(100)* {{%.*}}, i64 -1
42 ; CHECK: store double 0.000000e+00, double addrspace(100)*