diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-11-20 01:12:50 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-11-20 01:12:50 +0000 |
commit | f5837aacd4b04e551fb194f4095006b7e6f2b991 (patch) | |
tree | 9867d2cba4b2601ff14dc290d1c86970f5e94ff9 /test/Transforms | |
parent | 1f9f73a4c647cc37ea9568d3791599f4daf384fe (diff) | |
download | external_llvm-f5837aacd4b04e551fb194f4095006b7e6f2b991.zip external_llvm-f5837aacd4b04e551fb194f4095006b7e6f2b991.tar.gz external_llvm-f5837aacd4b04e551fb194f4095006b7e6f2b991.tar.bz2 |
Rework the rewriting of loads and stores for vector and integer allocas
to properly handle the combinations of these with split integer loads
and stores. This essentially replaces Evan's r168227 by refactoring the
code in a different way, and trynig to mirror that refactoring in both
the load and store sides of the rewriting.
Generally speaking there was some really problematic duplicated code
here that led to poorly founded assumptions and then subtle bugs. Now
much of the code actually flows through and follows a more consistent
style and logical path. There is still a tiny bit of duplication on the
store side of things, but it is much less bad.
This also changes the logic to never re-use a load or store instruction
as that was simply too error prone in practice.
I've added a few tests (one a reduction of the one in Evan's original
patch, which happened to be the same as the report in PR14349). I'm
going to look at adding a few more tests for things I found and fixed in
passing (such as the volatile tests in the vectorizable predicate).
This patch has survived bootstrap, and modulo one bugfix survived
Duncan's test suite, but let me know if anything else explodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168346 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r-- | test/Transforms/SROA/basictest.ll | 2 | ||||
-rw-r--r-- | test/Transforms/SROA/vector-extract.ll | 25 | ||||
-rw-r--r-- | test/Transforms/SROA/vector-promotion.ll | 45 |
3 files changed, 46 insertions, 26 deletions
diff --git a/test/Transforms/SROA/basictest.ll b/test/Transforms/SROA/basictest.ll index 110950f..b363eef 100644 --- a/test/Transforms/SROA/basictest.ll +++ b/test/Transforms/SROA/basictest.ll @@ -1100,12 +1100,12 @@ entry: %imag = getelementptr inbounds { float, float }* %retval, i32 0, i32 1 store float %phi.real, float* %real store float %phi.imag, float* %imag + ; CHECK-NEXT: %[[real_convert:.*]] = bitcast float %[[real]] to i32 ; CHECK-NEXT: %[[imag_convert:.*]] = bitcast float %[[imag]] to i32 ; CHECK-NEXT: %[[imag_ext:.*]] = zext i32 %[[imag_convert]] to i64 ; CHECK-NEXT: %[[imag_shift:.*]] = shl i64 %[[imag_ext]], 32 ; CHECK-NEXT: %[[imag_mask:.*]] = and i64 undef, 4294967295 ; CHECK-NEXT: %[[imag_insert:.*]] = or i64 %[[imag_mask]], %[[imag_shift]] - ; CHECK-NEXT: %[[real_convert:.*]] = bitcast float %[[real]] to i32 ; CHECK-NEXT: %[[real_ext:.*]] = zext i32 %[[real_convert]] to i64 ; CHECK-NEXT: %[[real_mask:.*]] = and i64 %[[imag_insert]], -4294967296 ; CHECK-NEXT: %[[real_insert:.*]] = or i64 %[[real_mask]], %[[real_ext]] diff --git a/test/Transforms/SROA/vector-extract.ll b/test/Transforms/SROA/vector-extract.ll deleted file mode 100644 index 2ca6168..0000000 --- a/test/Transforms/SROA/vector-extract.ll +++ /dev/null @@ -1,25 +0,0 @@ -; RUN: opt < %s -sroa -S | FileCheck %s -; rdar://12713675 - -target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" - -define <2 x i16> @test1(i64 %x) nounwind ssp { -; CHECK: @test1 -entry: - %tmp = alloca i64, align 8 - br i1 undef, label %bb1, label %bb2 -; CHECK-NOT: alloca - -bb1: - store i64 %x, i64* %tmp, align 8 -; CHECK-NOT: store - %0 = bitcast i64* %tmp to <2 x i16>* - %1 = load <2 x i16>* %0, align 8 -; CHECK-NOT: load -; CHECK: trunc i64 %x to i32 -; CHECK: bitcast i32 - ret <2 x i16> %1 - -bb2: - ret <2 x i16> < i16 0, i16 0 > -} diff --git a/test/Transforms/SROA/vector-promotion.ll b/test/Transforms/SROA/vector-promotion.ll index 02e084b..ea28f5d 100644 --- a/test/Transforms/SROA/vector-promotion.ll +++ b/test/Transforms/SROA/vector-promotion.ll @@ -220,3 +220,48 @@ entry: ret i32 %load ; CHECK: ret i32 } + +define <2 x i8> @PR14349.1(i32 %x) { +; CEHCK: @PR14349.1 +; The first testcase for broken SROA rewriting of split integer loads and +; stores due to smaller vector loads and stores. This particular test ensures +; that we can rewrite a split store of an integer to a store of a vector. +entry: + %a = alloca i32 +; CHECK-NOT: alloca + + store i32 %x, i32* %a +; CHECK-NOT: store + + %cast = bitcast i32* %a to <2 x i8>* + %vec = load <2 x i8>* %cast +; CHECK-NOT: load + + ret <2 x i8> %vec +; CHECK: %[[trunc:.*]] = trunc i32 %x to i16 +; CHECK: %[[cast:.*]] = bitcast i16 %[[trunc]] to <2 x i8> +; CHECK: ret <2 x i8> %[[cast]] +} + +define i32 @PR14349.2(<2 x i8> %x) { +; CEHCK: @PR14349.2 +; The first testcase for broken SROA rewriting of split integer loads and +; stores due to smaller vector loads and stores. This particular test ensures +; that we can rewrite a split load of an integer to a load of a vector. +entry: + %a = alloca i32 +; CHECK-NOT: alloca + + %cast = bitcast i32* %a to <2 x i8>* + store <2 x i8> %x, <2 x i8>* %cast +; CHECK-NOT: store + + %int = load i32* %a +; CHECK-NOT: load + + ret i32 %int +; CHECK: %[[cast:.*]] = bitcast <2 x i8> %x to i16 +; CHECK: %[[trunc:.*]] = zext i16 %[[cast]] to i32 +; CHECK: %[[insert:.*]] = or i32 %{{.*}}, %[[trunc]] +; CHECK: ret i32 %[[insert]] +} |