diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2014-10-21 09:00:40 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2014-10-21 09:00:40 +0000 |
commit | aa72a6dd3bd1a880e30c76545cdbb8928c104cd4 (patch) | |
tree | c9da6a60184c829830e1bab1a4fc246e21d221fd /llvm/test | |
parent | 592239d498c97c25d06eb76dad662df58c49a9b0 (diff) | |
download | bcm5719-llvm-aa72a6dd3bd1a880e30c76545cdbb8928c104cd4.tar.gz bcm5719-llvm-aa72a6dd3bd1a880e30c76545cdbb8928c104cd4.zip |
Teach the load analysis to allow finding available values which require
inttoptr or ptrtoint cast provided there is datalayout available.
Eventually, the datalayout can just be required but in practice it will
always be there today.
To go with the ability to expose available values requiring a ptrtoint
or inttoptr cast, helpers are added to perform one of these three casts.
These smarts are necessary to finish canonicalizing loads and stores to
the operational type requirements without regressing fundamental
combines.
I've added some test cases. These should actually improve as the load
combining and store combining improves, but they may fundamentally be
highlighting some missing combines for select in addition to exercising
the specific added logic to load analysis.
llvm-svn: 220277
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/Transforms/InstCombine/select.ll | 70 |
1 files changed, 61 insertions, 9 deletions
diff --git a/llvm/test/Transforms/InstCombine/select.ll b/llvm/test/Transforms/InstCombine/select.ll index 6cf9f0f6b4d..9c8286b9b1b 100644 --- a/llvm/test/Transforms/InstCombine/select.ll +++ b/llvm/test/Transforms/InstCombine/select.ll @@ -1256,7 +1256,7 @@ define i32 @test76(i1 %flag, i32* %x) { ret i32 %v } -declare void @scribble_on_memory(i32*) +declare void @scribble_on_i32(i32*) define i32 @test77(i1 %flag, i32* %x) { ; The load here must not be speculated around the select. One side of the @@ -1264,13 +1264,13 @@ define i32 @test77(i1 %flag, i32* %x) { ; load does. ; CHECK-LABEL: @test77( ; CHECK: %[[A:.*]] = alloca i32, align 1 -; CHECK: call void @scribble_on_memory(i32* %[[A]]) +; CHECK: call void @scribble_on_i32(i32* %[[A]]) ; CHECK: store i32 0, i32* %x ; CHECK: %[[P:.*]] = select i1 %flag, i32* %[[A]], i32* %x ; CHECK: load i32* %[[P]] %under_aligned = alloca i32, align 1 - call void @scribble_on_memory(i32* %under_aligned) + call void @scribble_on_i32(i32* %under_aligned) store i32 0, i32* %x %p = select i1 %flag, i32* %under_aligned, i32* %x %v = load i32* %p @@ -1327,8 +1327,8 @@ define i32 @test80(i1 %flag) { entry: %x = alloca i32 %y = alloca i32 - call void @scribble_on_memory(i32* %x) - call void @scribble_on_memory(i32* %y) + call void @scribble_on_i32(i32* %x) + call void @scribble_on_i32(i32* %y) %tmp = load i32* %x store i32 %tmp, i32* %y %p = select i1 %flag, i32* %x, i32* %y @@ -1351,8 +1351,8 @@ entry: %y = alloca i32 %x1 = bitcast float* %x to i32* %y1 = bitcast i32* %y to float* - call void @scribble_on_memory(i32* %x1) - call void @scribble_on_memory(i32* %y) + call void @scribble_on_i32(i32* %x1) + call void @scribble_on_i32(i32* %y) %tmp = load i32* %x1 store i32 %tmp, i32* %y %p = select i1 %flag, float* %x, float* %y1 @@ -1377,11 +1377,63 @@ entry: %y = alloca i32 %x1 = bitcast float* %x to i32* %y1 = bitcast i32* %y to float* - call void @scribble_on_memory(i32* %x1) - call void @scribble_on_memory(i32* %y) + call void @scribble_on_i32(i32* %x1) + call void @scribble_on_i32(i32* %y) %tmp = load float* %x store float %tmp, float* %y1 %p = select i1 %flag, i32* %x1, i32* %y %v = load i32* %p ret i32 %v } + +declare void @scribble_on_i64(i64*) + +define i8* @test83(i1 %flag) { +; Test that we can speculate the load around the select even though they use +; differently typed pointers and requires inttoptr casts. +; CHECK-LABEL: @test83( +; CHECK: %[[X:.*]] = alloca i8* +; CHECK-NEXT: %[[Y:.*]] = alloca i8* +; CHECK: %[[V:.*]] = load i64* %[[X]] +; CHECK-NEXT: %[[C1:.*]] = inttoptr i64 %[[V]] to i8* +; CHECK-NEXT: store i8* %[[C1]], i8** %[[Y]] +; CHECK-NEXT: %[[C2:.*]] = inttoptr i64 %[[V]] to i8* +; CHECK-NEXT: %[[S:.*]] = select i1 %flag, i8* %[[C2]], i8* %[[C1]] +; CHECK-NEXT: ret i8* %[[S]] +entry: + %x = alloca i8* + %y = alloca i64 + %x1 = bitcast i8** %x to i64* + %y1 = bitcast i64* %y to i8** + call void @scribble_on_i64(i64* %x1) + call void @scribble_on_i64(i64* %y) + %tmp = load i64* %x1 + store i64 %tmp, i64* %y + %p = select i1 %flag, i8** %x, i8** %y1 + %v = load i8** %p + ret i8* %v +} + +define i64 @test84(i1 %flag) { +; Test that we can speculate the load around the select even though they use +; differently typed pointers and requires a ptrtoint cast. +; CHECK-LABEL: @test84( +; CHECK: %[[X:.*]] = alloca i8* +; CHECK-NEXT: %[[Y:.*]] = alloca i8* +; CHECK: %[[V:.*]] = load i8** %[[X]] +; CHECK-NEXT: store i8* %[[V]], i8** %[[Y]] +; CHECK-NEXT: %[[C:.*]] = ptrtoint i8* %[[V]] to i64 +; CHECK-NEXT: ret i64 %[[C]] +entry: + %x = alloca i8* + %y = alloca i64 + %x1 = bitcast i8** %x to i64* + %y1 = bitcast i64* %y to i8** + call void @scribble_on_i64(i64* %x1) + call void @scribble_on_i64(i64* %y) + %tmp = load i8** %x + store i8* %tmp, i8** %y1 + %p = select i1 %flag, i64* %x1, i64* %y + %v = load i64* %p + ret i64 %v +} |