diff options
author | Chris Lattner <sabre@nondot.org> | 2009-12-06 01:57:02 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-12-06 01:57:02 +0000 |
commit | faf815b9380baef522becff67da7b9c3b0f1638d (patch) | |
tree | 30b8c600ae871883fa41461197b728ec862a1afa /test/Transforms/GVN/rle.ll | |
parent | 90ec9680a9b0c76bbc739d7309e4611b478ebe91 (diff) | |
download | external_llvm-faf815b9380baef522becff67da7b9c3b0f1638d.zip external_llvm-faf815b9380baef522becff67da7b9c3b0f1638d.tar.gz external_llvm-faf815b9380baef522becff67da7b9c3b0f1638d.tar.bz2 |
Handle forwarding local memsets to loads. For example, we optimize this:
short x(short *A) {
memset(A, 1, sizeof(*A)*100);
return A[42];
}
to 'return 257' instead of doing the load.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90695 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/GVN/rle.ll')
-rw-r--r-- | test/Transforms/GVN/rle.ll | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/Transforms/GVN/rle.ll b/test/Transforms/GVN/rle.ll index 71eb194..01d1ebc 100644 --- a/test/Transforms/GVN/rle.ll +++ b/test/Transforms/GVN/rle.ll @@ -131,6 +131,43 @@ define i8* @coerce_mustalias7(i64 %V, i64* %P) { ; CHECK: ret i8* } +; memset -> i16 forwarding. +define signext i16 @memset_to_i16_local(i16* %A) nounwind ssp { +entry: + %conv = bitcast i16* %A to i8* + tail call void @llvm.memset.i64(i8* %conv, i8 1, i64 200, i32 1) + %arrayidx = getelementptr inbounds i16* %A, i64 42 + %tmp2 = load i16* %arrayidx + ret i16 %tmp2 +; CHECK: @memset_to_i16_local +; CHECK-NOT: load +; CHECK: ret i16 257 +} + +; memset -> float forwarding. +define float @memset_to_float_local(float* %A, i8 %Val) nounwind ssp { +entry: + %conv = bitcast float* %A to i8* ; <i8*> [#uses=1] + tail call void @llvm.memset.i64(i8* %conv, i8 %Val, i64 400, i32 1) + %arrayidx = getelementptr inbounds float* %A, i64 42 ; <float*> [#uses=1] + %tmp2 = load float* %arrayidx ; <float> [#uses=1] + ret float %tmp2 +; CHECK: @memset_to_float_local +; CHECK-NOT: load +; CHECK: zext +; CHECK-NEXT: shl +; CHECK-NEXT: or +; CHECK-NEXT: shl +; CHECK-NEXT: or +; CHECK-NEXT: bitcast +; CHECK-NEXT: ret float +} + +declare void @llvm.memset.i64(i8* nocapture, i8, i64, i32) nounwind + + + + ;; non-local i32/float -> i8 load forwarding. define i8 @coerce_mustalias_nonlocal0(i32* %P, i1 %cond) { %P2 = bitcast i32* %P to float* |