Florian Hahn | 7902405 | 2019-01-04 14:53:22 +0000 | [diff] [blame] | 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" |
| 4 | |
| 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 } |
| 7 | |
| 8 | define void @test(i64 %n_chpl) { |
| 9 | entry: |
| 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 |
Michael Ferguson | e39b614 | 2019-01-07 21:02:22 +0000 | [diff] [blame] | 22 | ; These two stores refer to the same memory location |
| 23 | ; Even so, they are expected to remain separate stores here |
Florian Hahn | 7902405 | 2019-01-04 14:53:22 +0000 | [diff] [blame] | 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 |
| 33 | ret void |
| 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]] |
| 38 | ; CHECK: load |
| 39 | ; CHECK: getelementptr inbounds %ArrayImpl, %ArrayImpl addrspace(100)* |
| 40 | ; CHECK: load |
| 41 | ; CHECK: getelementptr inbounds double, double addrspace(100)* {{%.*}}, i64 -1 |
| 42 | ; CHECK: store double 0.000000e+00, double addrspace(100)* |
| 43 | ; CHECK: ret |
| 44 | } |