| Sanjay Patel | 1d04b5b | 2017-09-26 13:54:28 +0000 | [diff] [blame] | 1 | ; RUN: opt -S -dse -enable-dse-partial-store-merging=false < %s | FileCheck %s | 
| Hal Finkel | a127103 | 2016-06-23 13:46:39 +0000 | [diff] [blame] | 2 | target datalayout = "E-m:e-i64:64-n32:64" | 
|  | 3 | target triple = "powerpc64-bgq-linux" | 
|  | 4 |  | 
|  | 5 | %"struct.std::complex" = type { { float, float } } | 
|  | 6 |  | 
|  | 7 | define void @_Z4testSt7complexIfE(%"struct.std::complex"* noalias nocapture sret %agg.result, i64 %c.coerce) { | 
|  | 8 | entry: | 
|  | 9 | ; CHECK-LABEL: @_Z4testSt7complexIfE | 
|  | 10 |  | 
|  | 11 | %ref.tmp = alloca i64, align 8 | 
|  | 12 | %tmpcast = bitcast i64* %ref.tmp to %"struct.std::complex"* | 
|  | 13 | %c.sroa.0.0.extract.shift = lshr i64 %c.coerce, 32 | 
|  | 14 | %c.sroa.0.0.extract.trunc = trunc i64 %c.sroa.0.0.extract.shift to i32 | 
|  | 15 | %0 = bitcast i32 %c.sroa.0.0.extract.trunc to float | 
|  | 16 | %c.sroa.2.0.extract.trunc = trunc i64 %c.coerce to i32 | 
|  | 17 | %1 = bitcast i32 %c.sroa.2.0.extract.trunc to float | 
|  | 18 | call void @_Z3barSt7complexIfE(%"struct.std::complex"* nonnull sret %tmpcast, i64 %c.coerce) | 
|  | 19 | %2 = bitcast %"struct.std::complex"* %agg.result to i64* | 
|  | 20 | %3 = load i64, i64* %ref.tmp, align 8 | 
|  | 21 | store i64 %3, i64* %2, align 4 | 
|  | 22 | ; CHECK-NOT: store i64 | 
|  | 23 |  | 
|  | 24 | %_M_value.realp.i.i = getelementptr inbounds %"struct.std::complex", %"struct.std::complex"* %agg.result, i64 0, i32 0, i32 0 | 
|  | 25 | %4 = lshr i64 %3, 32 | 
|  | 26 | %5 = trunc i64 %4 to i32 | 
|  | 27 | %6 = bitcast i32 %5 to float | 
|  | 28 | %_M_value.imagp.i.i = getelementptr inbounds %"struct.std::complex", %"struct.std::complex"* %agg.result, i64 0, i32 0, i32 1 | 
|  | 29 | %7 = trunc i64 %3 to i32 | 
|  | 30 | %8 = bitcast i32 %7 to float | 
|  | 31 | %mul_ad.i.i = fmul fast float %6, %1 | 
|  | 32 | %mul_bc.i.i = fmul fast float %8, %0 | 
|  | 33 | %mul_i.i.i = fadd fast float %mul_ad.i.i, %mul_bc.i.i | 
|  | 34 | %mul_ac.i.i = fmul fast float %6, %0 | 
|  | 35 | %mul_bd.i.i = fmul fast float %8, %1 | 
|  | 36 | %mul_r.i.i = fsub fast float %mul_ac.i.i, %mul_bd.i.i | 
|  | 37 | store float %mul_r.i.i, float* %_M_value.realp.i.i, align 4 | 
|  | 38 | store float %mul_i.i.i, float* %_M_value.imagp.i.i, align 4 | 
|  | 39 | ret void | 
|  | 40 | ; CHECK: ret void | 
|  | 41 | } | 
|  | 42 |  | 
|  | 43 | declare void @_Z3barSt7complexIfE(%"struct.std::complex"* sret, i64) | 
|  | 44 |  | 
|  | 45 | define void @test1(i32 *%ptr) { | 
|  | 46 | entry: | 
|  | 47 | ; CHECK-LABEL: @test1 | 
|  | 48 |  | 
|  | 49 | store i32 5, i32* %ptr | 
|  | 50 | %bptr = bitcast i32* %ptr to i8* | 
|  | 51 | store i8 7, i8* %bptr | 
|  | 52 | %wptr = bitcast i32* %ptr to i16* | 
|  | 53 | store i16 -30062, i16* %wptr | 
|  | 54 | %bptr2 = getelementptr inbounds i8, i8* %bptr, i64 2 | 
|  | 55 | store i8 25, i8* %bptr2 | 
|  | 56 | %bptr3 = getelementptr inbounds i8, i8* %bptr, i64 3 | 
|  | 57 | store i8 47, i8* %bptr3 | 
|  | 58 | %bptr1 = getelementptr inbounds i8, i8* %bptr, i64 1 | 
|  | 59 | %wptrp = bitcast i8* %bptr1 to i16* | 
|  | 60 | store i16 2020, i16* %wptrp, align 1 | 
|  | 61 | ret void | 
|  | 62 |  | 
|  | 63 | ; CHECK-NOT: store i32 5, i32* %ptr | 
|  | 64 | ; CHECK-NOT: store i8 7, i8* %bptr | 
|  | 65 | ; CHECK: store i16 -30062, i16* %wptr | 
|  | 66 | ; CHECK-NOT: store i8 25, i8* %bptr2 | 
|  | 67 | ; CHECK: store i8 47, i8* %bptr3 | 
|  | 68 | ; CHECK: store i16 2020, i16* %wptrp, align 1 | 
|  | 69 |  | 
|  | 70 | ; CHECK: ret void | 
|  | 71 | } | 
|  | 72 |  | 
|  | 73 | define void @test2(i32 *%ptr) { | 
|  | 74 | entry: | 
|  | 75 | ; CHECK-LABEL: @test2 | 
|  | 76 |  | 
|  | 77 | store i32 5, i32* %ptr | 
|  | 78 |  | 
|  | 79 | %bptr = bitcast i32* %ptr to i8* | 
|  | 80 | %bptrm1 = getelementptr inbounds i8, i8* %bptr, i64 -1 | 
|  | 81 | %bptr1 = getelementptr inbounds i8, i8* %bptr, i64 1 | 
|  | 82 | %bptr2 = getelementptr inbounds i8, i8* %bptr, i64 2 | 
|  | 83 | %bptr3 = getelementptr inbounds i8, i8* %bptr, i64 3 | 
|  | 84 |  | 
|  | 85 | %wptr = bitcast i8* %bptr to i16* | 
|  | 86 | %wptrm1 = bitcast i8* %bptrm1 to i16* | 
|  | 87 | %wptr1 = bitcast i8* %bptr1 to i16* | 
|  | 88 | %wptr2 = bitcast i8* %bptr2 to i16* | 
|  | 89 | %wptr3 = bitcast i8* %bptr3 to i16* | 
|  | 90 |  | 
|  | 91 | store i16 1456, i16* %wptrm1, align 1 | 
|  | 92 | store i16 1346, i16* %wptr, align 1 | 
|  | 93 | store i16 1756, i16* %wptr1, align 1 | 
|  | 94 | store i16 1126, i16* %wptr2, align 1 | 
|  | 95 | store i16 5656, i16* %wptr3, align 1 | 
|  | 96 |  | 
|  | 97 | ; CHECK-NOT: store i32 5, i32* %ptr | 
|  | 98 |  | 
|  | 99 | ; CHECK: store i16 1456, i16* %wptrm1, align 1 | 
|  | 100 | ; CHECK: store i16 1346, i16* %wptr, align 1 | 
|  | 101 | ; CHECK: store i16 1756, i16* %wptr1, align 1 | 
|  | 102 | ; CHECK: store i16 1126, i16* %wptr2, align 1 | 
|  | 103 | ; CHECK: store i16 5656, i16* %wptr3, align 1 | 
|  | 104 |  | 
|  | 105 | ret void | 
|  | 106 |  | 
|  | 107 | ; CHECK: ret void | 
|  | 108 | } | 
|  | 109 |  | 
|  | 110 | define signext i8 @test3(i32 *%ptr) { | 
|  | 111 | entry: | 
|  | 112 | ; CHECK-LABEL: @test3 | 
|  | 113 |  | 
|  | 114 | store i32 5, i32* %ptr | 
|  | 115 |  | 
|  | 116 | %bptr = bitcast i32* %ptr to i8* | 
|  | 117 | %bptrm1 = getelementptr inbounds i8, i8* %bptr, i64 -1 | 
|  | 118 | %bptr1 = getelementptr inbounds i8, i8* %bptr, i64 1 | 
|  | 119 | %bptr2 = getelementptr inbounds i8, i8* %bptr, i64 2 | 
|  | 120 | %bptr3 = getelementptr inbounds i8, i8* %bptr, i64 3 | 
|  | 121 |  | 
|  | 122 | %wptr = bitcast i8* %bptr to i16* | 
|  | 123 | %wptrm1 = bitcast i8* %bptrm1 to i16* | 
|  | 124 | %wptr1 = bitcast i8* %bptr1 to i16* | 
|  | 125 | %wptr2 = bitcast i8* %bptr2 to i16* | 
|  | 126 | %wptr3 = bitcast i8* %bptr3 to i16* | 
|  | 127 |  | 
|  | 128 | %v = load i8, i8* %bptr, align 1 | 
|  | 129 | store i16 1456, i16* %wptrm1, align 1 | 
|  | 130 | store i16 1346, i16* %wptr, align 1 | 
|  | 131 | store i16 1756, i16* %wptr1, align 1 | 
|  | 132 | store i16 1126, i16* %wptr2, align 1 | 
|  | 133 | store i16 5656, i16* %wptr3, align 1 | 
|  | 134 |  | 
|  | 135 | ; CHECK: store i32 5, i32* %ptr | 
|  | 136 |  | 
|  | 137 | ret i8 %v | 
|  | 138 |  | 
|  | 139 | ; CHECK: ret i8 %v | 
|  | 140 | } | 
|  | 141 |  | 
|  | 142 | %struct.foostruct = type { | 
|  | 143 | i32 (i8*, i8**, i32, i8, i8*)*, | 
|  | 144 | i32 (i8*, i8**, i32, i8, i8*)*, | 
|  | 145 | i32 (i8*, i8**, i32, i8, i8*)*, | 
|  | 146 | i32 (i8*, i8**, i32, i8, i8*)*, | 
|  | 147 | void (i8*, i32, i32)* | 
|  | 148 | } | 
| Daniel Neilson | 1e68724 | 2018-01-19 17:13:12 +0000 | [diff] [blame] | 149 | declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1) | 
| Hal Finkel | a127103 | 2016-06-23 13:46:39 +0000 | [diff] [blame] | 150 | declare void @goFunc(%struct.foostruct*) | 
|  | 151 | declare i32 @fa(i8*, i8**, i32, i8, i8*) | 
|  | 152 |  | 
|  | 153 | define void @test4()  { | 
|  | 154 | entry: | 
|  | 155 | ; CHECK-LABEL: @test4 | 
|  | 156 |  | 
|  | 157 | %bang = alloca %struct.foostruct, align 8 | 
|  | 158 | %v1 = bitcast %struct.foostruct* %bang to i8* | 
| Daniel Neilson | 1e68724 | 2018-01-19 17:13:12 +0000 | [diff] [blame] | 159 | call void @llvm.memset.p0i8.i64(i8* align 8 %v1, i8 0, i64 40, i1 false) | 
| Hal Finkel | a127103 | 2016-06-23 13:46:39 +0000 | [diff] [blame] | 160 | %v2 = getelementptr inbounds %struct.foostruct, %struct.foostruct* %bang, i64 0, i32 0 | 
|  | 161 | store i32 (i8*, i8**, i32, i8, i8*)* @fa, i32 (i8*, i8**, i32, i8, i8*)** %v2, align 8 | 
|  | 162 | %v3 = getelementptr inbounds %struct.foostruct, %struct.foostruct* %bang, i64 0, i32 1 | 
|  | 163 | store i32 (i8*, i8**, i32, i8, i8*)* @fa, i32 (i8*, i8**, i32, i8, i8*)** %v3, align 8 | 
|  | 164 | %v4 = getelementptr inbounds %struct.foostruct, %struct.foostruct* %bang, i64 0, i32 2 | 
|  | 165 | store i32 (i8*, i8**, i32, i8, i8*)* @fa, i32 (i8*, i8**, i32, i8, i8*)** %v4, align 8 | 
|  | 166 | %v5 = getelementptr inbounds %struct.foostruct, %struct.foostruct* %bang, i64 0, i32 3 | 
|  | 167 | store i32 (i8*, i8**, i32, i8, i8*)* @fa, i32 (i8*, i8**, i32, i8, i8*)** %v5, align 8 | 
|  | 168 | %v6 = getelementptr inbounds %struct.foostruct, %struct.foostruct* %bang, i64 0, i32 4 | 
|  | 169 | store void (i8*, i32, i32)* null, void (i8*, i32, i32)** %v6, align 8 | 
|  | 170 | call void @goFunc(%struct.foostruct* %bang) | 
|  | 171 | ret void | 
|  | 172 |  | 
|  | 173 | ; CHECK-NOT: memset | 
|  | 174 | ; CHECK: ret void | 
|  | 175 | } | 
|  | 176 |  | 
|  | 177 | define signext i8 @test5(i32 *%ptr) { | 
|  | 178 | entry: | 
|  | 179 | ; CHECK-LABEL: @test5 | 
|  | 180 |  | 
|  | 181 | store i32 0, i32* %ptr | 
|  | 182 |  | 
|  | 183 | %bptr = bitcast i32* %ptr to i8* | 
|  | 184 | %bptr1 = getelementptr inbounds i8, i8* %bptr, i64 1 | 
|  | 185 | %bptr2 = getelementptr inbounds i8, i8* %bptr, i64 2 | 
|  | 186 | %bptr3 = getelementptr inbounds i8, i8* %bptr, i64 3 | 
|  | 187 |  | 
|  | 188 | %wptr = bitcast i8* %bptr to i16* | 
|  | 189 | %wptr1 = bitcast i8* %bptr1 to i16* | 
|  | 190 | %wptr2 = bitcast i8* %bptr2 to i16* | 
|  | 191 |  | 
|  | 192 | store i16 65535, i16* %wptr2, align 1 | 
|  | 193 | store i16 1456, i16* %wptr1, align 1 | 
|  | 194 | store i16 1346, i16* %wptr, align 1 | 
|  | 195 |  | 
|  | 196 | ; CHECK-NOT: store i32 0, i32* %ptr | 
|  | 197 |  | 
|  | 198 | ret i8 0 | 
|  | 199 | } | 
|  | 200 |  | 
| Jun Bum Lim | 596a3bd | 2016-06-30 15:32:20 +0000 | [diff] [blame] | 201 | define signext i8 @test6(i32 *%ptr) { | 
|  | 202 | entry: | 
|  | 203 | ; CHECK-LABEL: @test6 | 
|  | 204 |  | 
|  | 205 | store i32 0, i32* %ptr | 
|  | 206 |  | 
|  | 207 | %bptr = bitcast i32* %ptr to i16* | 
|  | 208 | %bptr1 = getelementptr inbounds i16, i16* %bptr, i64 0 | 
|  | 209 | %bptr2 = getelementptr inbounds i16, i16* %bptr, i64 1 | 
|  | 210 |  | 
|  | 211 | store i16 1456, i16* %bptr2, align 1 | 
|  | 212 | store i16 65535, i16* %bptr1, align 1 | 
|  | 213 |  | 
|  | 214 | ; CHECK-NOT: store i32 0, i32* %ptr | 
|  | 215 |  | 
|  | 216 | ret i8 0 | 
|  | 217 | } | 
|  | 218 |  | 
|  | 219 | define signext i8 @test7(i64 *%ptr) { | 
|  | 220 | entry: | 
|  | 221 | ; CHECK-LABEL: @test7 | 
|  | 222 |  | 
|  | 223 | store i64 0, i64* %ptr | 
|  | 224 |  | 
|  | 225 | %bptr = bitcast i64* %ptr to i16* | 
|  | 226 | %bptr1 = getelementptr inbounds i16, i16* %bptr, i64 0 | 
|  | 227 | %bptr2 = getelementptr inbounds i16, i16* %bptr, i64 1 | 
|  | 228 | %bptr3 = getelementptr inbounds i16, i16* %bptr, i64 2 | 
|  | 229 | %bptr4 = getelementptr inbounds i16, i16* %bptr, i64 3 | 
|  | 230 |  | 
|  | 231 | store i16 1346, i16* %bptr1, align 1 | 
|  | 232 | store i16 1756, i16* %bptr3, align 1 | 
|  | 233 | store i16 1456, i16* %bptr2, align 1 | 
|  | 234 | store i16 5656, i16* %bptr4, align 1 | 
|  | 235 |  | 
|  | 236 | ; CHECK-NOT: store i64 0, i64* %ptr | 
|  | 237 |  | 
|  | 238 | ret i8 0 | 
|  | 239 | } |