1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=dse -enable-dse-partial-store-merging=false -S | FileCheck %s
3 target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
5 ; Ensure that the dead store is deleted in this case. It is wholely
6 ; overwritten by the second store.
7 define void @test1(ptr %V) {
9 ; CHECK-NEXT: store i32 1234567, ptr [[V:%.*]], align 4
10 ; CHECK-NEXT: ret void
13 store i32 1234567, ptr %V
17 ; Note that we could do better by merging the two stores into one.
18 define void @test2(ptr %P) {
19 ; CHECK-LABEL: @test2(
20 ; CHECK-NEXT: store i32 0, ptr [[P:%.*]], align 4
21 ; CHECK-NEXT: store i16 1, ptr [[P]], align 2
22 ; CHECK-NEXT: ret void
30 define i32 @test3(double %__x) {
31 ; CHECK-LABEL: @test3(
32 ; CHECK-NEXT: [[__U:%.*]] = alloca { [3 x i32] }, align 4
33 ; CHECK-NEXT: store double [[__X:%.*]], ptr [[__U]], align 8
34 ; CHECK-NEXT: [[TMP_4:%.*]] = getelementptr { [3 x i32] }, ptr [[__U]], i32 0, i32 0, i32 1
35 ; CHECK-NEXT: [[TMP_5:%.*]] = load i32, ptr [[TMP_4]], align 4
36 ; CHECK-NEXT: [[TMP_6:%.*]] = icmp slt i32 [[TMP_5]], 0
37 ; CHECK-NEXT: [[TMP_7:%.*]] = zext i1 [[TMP_6]] to i32
38 ; CHECK-NEXT: ret i32 [[TMP_7]]
40 %__u = alloca { [3 x i32] }
41 store double %__x, ptr %__u
42 %tmp.4 = getelementptr { [3 x i32] }, ptr %__u, i32 0, i32 0, i32 1
43 %tmp.5 = load i32, ptr %tmp.4
44 %tmp.6 = icmp slt i32 %tmp.5, 0
45 %tmp.7 = zext i1 %tmp.6 to i32
50 define void @test4(ptr %P) {
51 ; CHECK-LABEL: @test4(
52 ; CHECK-NEXT: store double 0.000000e+00, ptr [[P:%.*]], align 8
53 ; CHECK-NEXT: ret void
56 store i8 19, ptr %P ;; dead
57 %A = getelementptr i8, ptr %P, i32 3
59 store i8 42, ptr %A ;; dead
61 store double 0.0, ptr %P
66 declare void @test5a(ptr)
67 define void @test5(i32 %i) nounwind ssp {
68 ; CHECK-LABEL: @test5(
69 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
70 ; CHECK-NEXT: store i32 20, ptr [[A]], align 4
71 ; CHECK-NEXT: call void @test5a(ptr [[A]])
72 ; CHECK-NEXT: ret void
75 %C = getelementptr i8, ptr %A, i32 %i
76 store i8 10, ptr %C ;; Dead store to variable index.
79 call void @test5a(ptr %A)
83 declare void @test5a_as1(ptr)
84 define void @test5_addrspacecast(i32 %i) nounwind ssp {
85 ; CHECK-LABEL: @test5_addrspacecast(
86 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
87 ; CHECK-NEXT: store i32 20, ptr [[A]], align 4
88 ; CHECK-NEXT: call void @test5a(ptr [[A]])
89 ; CHECK-NEXT: ret void
92 %B = addrspacecast ptr %A to ptr addrspace(1)
93 %C = getelementptr i8, ptr addrspace(1) %B, i32 %i
94 store i8 10, ptr addrspace(1) %C ;; Dead store to variable index.
97 call void @test5a(ptr %A)