diff options
author | Chris Lattner <sabre@nondot.org> | 2009-09-20 19:03:47 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-09-20 19:03:47 +0000 |
commit | bb6495cc673db919225768a62872b79205a3af41 (patch) | |
tree | de8a70bb65aa95eddbe7795741cf7e390ee44dfa /test/Transforms/GVN/rle.ll | |
parent | c1491f3c47617dedc52b6e9557fa53c24c10c98b (diff) | |
download | external_llvm-bb6495cc673db919225768a62872b79205a3af41.zip external_llvm-bb6495cc673db919225768a62872b79205a3af41.tar.gz external_llvm-bb6495cc673db919225768a62872b79205a3af41.tar.bz2 |
enhance GVN to forward substitute a stored value to a load
(and load -> load) when the base pointers must alias but when
they are different types. This occurs very very frequently in
176.gcc and other code that uses bitfields a lot.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82399 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/GVN/rle.ll')
-rw-r--r-- | test/Transforms/GVN/rle.ll | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/test/Transforms/GVN/rle.ll b/test/Transforms/GVN/rle.ll new file mode 100644 index 0000000..cd3a611 --- /dev/null +++ b/test/Transforms/GVN/rle.ll @@ -0,0 +1,119 @@ +; RUN: opt < %s -gvn -S | FileCheck %s + +; 32-bit little endian target. +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" + +;; Trivial RLE test. +define i32 @test0(i32 %V, i32* %P) { + store i32 %V, i32* %P + + %A = load i32* %P + ret i32 %A +; CHECK: @test0 +; CHECK: ret i32 %V +} + +;;===----------------------------------------------------------------------===;; +;; Store -> Load and Load -> Load forwarding where src and dst are different +;; types, but where the base pointer is a must alias. +;;===----------------------------------------------------------------------===;; + +;; i32 -> f32 forwarding. +define float @coerce_mustalias1(i32 %V, i32* %P) { + store i32 %V, i32* %P + + %P2 = bitcast i32* %P to float* + + %A = load float* %P2 + ret float %A +; CHECK: @coerce_mustalias1 +; CHECK-NOT: load +; CHECK: ret float +} + +;; i32* -> float forwarding. +define float @coerce_mustalias2(i32* %V, i32** %P) { + store i32* %V, i32** %P + + %P2 = bitcast i32** %P to float* + + %A = load float* %P2 + ret float %A +; CHECK: @coerce_mustalias2 +; CHECK-NOT: load +; CHECK: ret float +} + +;; float -> i32* forwarding. +define i32* @coerce_mustalias3(float %V, float* %P) { + store float %V, float* %P + + %P2 = bitcast float* %P to i32** + + %A = load i32** %P2 + ret i32* %A +; CHECK: @coerce_mustalias3 +; CHECK-NOT: load +; CHECK: ret i32* +} + +;; i32 -> f32 load forwarding. +define float @coerce_mustalias4(i32* %P, i1 %cond) { + %A = load i32* %P + br i1 %cond, label %T, label %T +T: + %P2 = bitcast i32* %P to float* + + %B = load float* %P2 + ret float %B + +F: + %X = bitcast i32 %A to float + ret float %X + +; CHECK: @coerce_mustalias4 +; CHECK: %A = load i32* %P +; CHECK-NOT: load +; CHECK: ret float +; CHECK: F: +} + +;; i32 -> i8 forwarding +define i8 @coerce_mustalias5(i32 %V, i32* %P) { + store i32 %V, i32* %P + + %P2 = bitcast i32* %P to i8* + + %A = load i8* %P2 + ret i8 %A +; CHECK: @coerce_mustalias5 +; CHECK-NOT: load +; CHECK: ret i8 +} + +;; i64 -> float forwarding +define float @coerce_mustalias6(i64 %V, i64* %P) { + store i64 %V, i64* %P + + %P2 = bitcast i64* %P to float* + + %A = load float* %P2 + ret float %A +; CHECK: @coerce_mustalias6 +; CHECK-NOT: load +; CHECK: ret float +} + +;; i64 -> i8* (32-bit) forwarding +define i8* @coerce_mustalias7(i64 %V, i64* %P) { + store i64 %V, i64* %P + + %P2 = bitcast i64* %P to i8** + + %A = load i8** %P2 + ret i8* %A +; CHECK: @coerce_mustalias7 +; CHECK-NOT: load +; CHECK: ret i8* +} + |