45 lines · plain
1; RUN: opt -passes=gvn -S < %s | FileCheck %s2target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-p100:128:64:64-p101:128:64:64"3target triple = "x86_64-unknown-linux-gnu"4 5%ArrayImpl = type { i64, ptr addrspace(100), [1 x i64], [1 x i64], [1 x i64], i64, i64, ptr addrspace(100), ptr addrspace(100), i8, i64 }6%_array = type { i64, ptr addrspace(100), i8 }7 8define void @test(i64 %n_chpl) null_pointer_is_valid {9entry:10 ; First section is some code11 %0 = getelementptr inbounds %_array, ptr null, i32 0, i32 112 %1 = load ptr addrspace(100), ptr %013 %2 = getelementptr inbounds %ArrayImpl, ptr addrspace(100) %1, i32 0, i32 814 %3 = load ptr addrspace(100), ptr addrspace(100) %215 %4 = getelementptr inbounds double, ptr addrspace(100) %3, i64 -116 ; Second section is that code repeated17 %x0 = getelementptr inbounds %_array, ptr null, i32 0, i32 118 %x1 = load ptr addrspace(100), ptr %x019 %x2 = getelementptr inbounds %ArrayImpl, ptr addrspace(100) %x1, i32 0, i32 820 %x3 = load ptr addrspace(100), ptr addrspace(100) %x221 %x4 = getelementptr inbounds double, ptr addrspace(100) %x3, i64 -122 ; These two stores refer to the same memory location23 ; Even so, they are expected to remain separate stores here24 store double 0.000000e+00, ptr addrspace(100) %425 store double 0.000000e+00, ptr addrspace(100) %x426 ; Third section is the repeated code again, with a later store27 ; This third section is necessary to trigger the crash28 %y1 = load ptr addrspace(100), ptr %029 %y2 = getelementptr inbounds %ArrayImpl, ptr addrspace(100) %y1, i32 0, i32 830 %y3 = load ptr addrspace(100), ptr addrspace(100) %y231 %y4 = getelementptr inbounds double, ptr addrspace(100) %y3, i64 -132 store double 0.000000e+00, ptr addrspace(100) %y433 ret void34; CHECK-LABEL: define void @test35; CHECK: getelementptr inbounds double, ptr addrspace(100) {{%.*}}, i64 -136; CHECK-NEXT: store double 0.000000e+00, ptr addrspace(100) [[DST:%.*]]37; CHECK-NEXT: store double 0.000000e+00, ptr addrspace(100) [[DST]]38; CHECK: load39; CHECK: getelementptr inbounds %ArrayImpl, ptr addrspace(100)40; CHECK: load41; CHECK: getelementptr inbounds double, ptr addrspace(100) {{%.*}}, i64 -142; CHECK: store double 0.000000e+00, ptr addrspace(100)43; CHECK: ret44}45