llvm.org GIT mirror llvm / 41bfbb0
Stores of null pointers should turn into memset, we weren't recognizing them as splat values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126041 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 8 years ago
2 changed file(s) with 28 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
11621162 Value *llvm::isBytewiseValue(Value *V) {
11631163 // All byte-wide stores are splatable, even of arbitrary variables.
11641164 if (V->getType()->isIntegerTy(8)) return V;
1165
1166 // Handle 'null' ConstantArrayZero etc.
1167 if (Constant *C = dyn_cast(V))
1168 if (C->isNullValue())
1169 return Constant::getNullValue(Type::getInt8Ty(V->getContext()));
11651170
11661171 // Constant float and double values can be handled as integer values if the
11671172 // corresponding integer value is "byteable". An important case is 0.0.
298298 ; CHECK: ret void
299299 }
300300
301
301 ; Store of null should turn into memset of zero.
302 define void @test12(i32** nocapture %P) nounwind ssp {
303 entry:
304 br label %for.body
305
306 for.body: ; preds = %entry, %for.body
307 %indvar = phi i64 [ 0, %entry ], [ %indvar.next, %for.body ]
308 %arrayidx = getelementptr i32** %P, i64 %indvar
309 store i32* null, i32** %arrayidx, align 4
310 %indvar.next = add i64 %indvar, 1
311 %exitcond = icmp eq i64 %indvar.next, 10000
312 br i1 %exitcond, label %for.end, label %for.body
313
314 for.end: ; preds = %for.body
315 ret void
316 ; CHECK: @test12
317 ; CHECK-NEXT: entry:
318 ; CHECK-NEXT: bitcast
319 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* %P1, i8 0, i64 80000, i32 4, i1 false)
320 ; CHECK-NOT: store
321 ; CHECK: ret void
322 }
323