Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Scalarizer] No need to gather a scattered extracted element
ExtractElement does not produce a vector out of a vector, so there's no need to call a gather once done. Fix #54469 Credits to npopov@redhat.com for the original approach. Differential Revision: https://reviews.llvm.org/D126012
- Loading branch information
serge-sans-paille
committed
Jun 21, 2022
1 parent
271cc58
commit aaf1630
Showing
3 changed files
with
117 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
llvm/test/Transforms/Scalarizer/vector-of-pointer-to-vector.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
; RUN: opt %s -passes='function(scalarizer,dce)' -scalarize-load-store -S | FileCheck %s | ||
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 <1 x i32> @f1(<1 x <1 x i32>*> %src, i32 %index) { | ||
; CHECK-LABEL: @f1( | ||
; CHECK-NEXT: [[INDEX_IS_0:%.*]] = icmp eq i32 [[INDEX:%.*]], 0 | ||
; CHECK-NEXT: [[SRC_I0:%.*]] = extractelement <1 x <1 x i32>*> [[SRC:%.*]], i32 0 | ||
; CHECK-NEXT: [[DOTUPTO0:%.*]] = select i1 [[INDEX_IS_0]], <1 x i32>* [[SRC_I0]], <1 x i32>* undef | ||
; CHECK-NEXT: [[DOTUPTO0_I0:%.*]] = bitcast <1 x i32>* [[DOTUPTO0]] to i32* | ||
; CHECK-NEXT: [[DOTI0:%.*]] = load i32, i32* [[DOTUPTO0_I0]], align 4 | ||
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <1 x i32> poison, i32 [[DOTI0]], i32 0 | ||
; CHECK-NEXT: ret <1 x i32> [[TMP1]] | ||
; | ||
%1 = extractelement <1 x <1 x i32>*> %src, i32 %index | ||
%2 = load <1 x i32>, <1 x i32>* %1, align 4 | ||
ret <1 x i32> %2 | ||
} | ||
|
||
define <1 x i32> @f1b(<1 x <1 x i32>*> %src) { | ||
; CHECK-LABEL: @f1b( | ||
; CHECK-NEXT: [[SRC_I0:%.*]] = extractelement <1 x <1 x i32>*> [[SRC:%.*]], i32 0 | ||
; CHECK-NEXT: [[SRC_I0_I0:%.*]] = bitcast <1 x i32>* [[SRC_I0]] to i32* | ||
; CHECK-NEXT: [[DOTI0:%.*]] = load i32, i32* [[SRC_I0_I0]], align 4 | ||
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <1 x i32> poison, i32 [[DOTI0]], i32 0 | ||
; CHECK-NEXT: ret <1 x i32> [[TMP1]] | ||
; | ||
%1 = extractelement <1 x <1 x i32>*> %src, i32 0 | ||
%2 = load <1 x i32>, <1 x i32>* %1, align 4 | ||
ret <1 x i32> %2 | ||
} | ||
|
||
define <2 x i32> @f2(<1 x <2 x i32>*> %src, i32 %index) { | ||
; CHECK-LABEL: @f2( | ||
; CHECK-NEXT: [[INDEX_IS_0:%.*]] = icmp eq i32 [[INDEX:%.*]], 0 | ||
; CHECK-NEXT: [[SRC_I0:%.*]] = extractelement <1 x <2 x i32>*> [[SRC:%.*]], i32 0 | ||
; CHECK-NEXT: [[DOTUPTO0:%.*]] = select i1 [[INDEX_IS_0]], <2 x i32>* [[SRC_I0]], <2 x i32>* undef | ||
; CHECK-NEXT: [[DOTUPTO0_I0:%.*]] = bitcast <2 x i32>* [[DOTUPTO0]] to i32* | ||
; CHECK-NEXT: [[DOTUPTO0_I1:%.*]] = getelementptr i32, i32* [[DOTUPTO0_I0]], i32 1 | ||
; CHECK-NEXT: [[DOTI0:%.*]] = load i32, i32* [[DOTUPTO0_I0]], align 4 | ||
; CHECK-NEXT: [[DOTI1:%.*]] = load i32, i32* [[DOTUPTO0_I1]], align 4 | ||
; CHECK-NEXT: [[DOTUPTO01:%.*]] = insertelement <2 x i32> poison, i32 [[DOTI0]], i32 0 | ||
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x i32> [[DOTUPTO01]], i32 [[DOTI1]], i32 1 | ||
; CHECK-NEXT: ret <2 x i32> [[TMP1]] | ||
; | ||
%1 = extractelement <1 x <2 x i32>*> %src, i32 %index | ||
%2 = load <2 x i32>, <2 x i32>* %1, align 4 | ||
ret <2 x i32> %2 | ||
} | ||
|
||
define <2 x i32> @f2b(<1 x <2 x i32>*> %src) { | ||
; CHECK-LABEL: @f2b( | ||
; CHECK-NEXT: [[SRC_I0:%.*]] = extractelement <1 x <2 x i32>*> [[SRC:%.*]], i32 0 | ||
; CHECK-NEXT: [[SRC_I0_I0:%.*]] = bitcast <2 x i32>* [[SRC_I0]] to i32* | ||
; CHECK-NEXT: [[SRC_I0_I1:%.*]] = getelementptr i32, i32* [[SRC_I0_I0]], i32 1 | ||
; CHECK-NEXT: [[DOTI0:%.*]] = load i32, i32* [[SRC_I0_I0]], align 4 | ||
; CHECK-NEXT: [[DOTI1:%.*]] = load i32, i32* [[SRC_I0_I1]], align 4 | ||
; CHECK-NEXT: [[DOTUPTO0:%.*]] = insertelement <2 x i32> poison, i32 [[DOTI0]], i32 0 | ||
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x i32> [[DOTUPTO0]], i32 [[DOTI1]], i32 1 | ||
; CHECK-NEXT: ret <2 x i32> [[TMP1]] | ||
; | ||
%1 = extractelement <1 x <2 x i32>*> %src, i32 0 | ||
%2 = load <2 x i32>, <2 x i32>* %1, align 4 | ||
ret <2 x i32> %2 | ||
} | ||
|
||
define void @f3(<1 x <2 x i32>*> %src, i32 %index, <2 x i32> %val) { | ||
; CHECK-LABEL: @f3( | ||
; CHECK-NEXT: [[VAL_I0:%.*]] = extractelement <2 x i32> [[VAL:%.*]], i32 0 | ||
; CHECK-NEXT: [[VAL_I1:%.*]] = extractelement <2 x i32> [[VAL]], i32 1 | ||
; CHECK-NEXT: [[INDEX_IS_0:%.*]] = icmp eq i32 [[INDEX:%.*]], 0 | ||
; CHECK-NEXT: [[SRC_I0:%.*]] = extractelement <1 x <2 x i32>*> [[SRC:%.*]], i32 0 | ||
; CHECK-NEXT: [[DOTUPTO0:%.*]] = select i1 [[INDEX_IS_0]], <2 x i32>* [[SRC_I0]], <2 x i32>* undef | ||
; CHECK-NEXT: [[DOTUPTO0_I0:%.*]] = bitcast <2 x i32>* [[DOTUPTO0]] to i32* | ||
; CHECK-NEXT: [[DOTUPTO0_I1:%.*]] = getelementptr i32, i32* [[DOTUPTO0_I0]], i32 1 | ||
; CHECK-NEXT: store i32 [[VAL_I0]], i32* [[DOTUPTO0_I0]], align 4 | ||
; CHECK-NEXT: store i32 [[VAL_I1]], i32* [[DOTUPTO0_I1]], align 4 | ||
; CHECK-NEXT: ret void | ||
; | ||
%1 = extractelement <1 x <2 x i32>*> %src, i32 %index | ||
store <2 x i32> %val, <2 x i32>* %1, align 4 | ||
ret void | ||
} | ||
|
||
define void @f3b(<1 x <2 x i32>*> %src, <2 x i32> %val) { | ||
; CHECK-LABEL: @f3b( | ||
; CHECK-NEXT: [[VAL_I0:%.*]] = extractelement <2 x i32> [[VAL:%.*]], i32 0 | ||
; CHECK-NEXT: [[VAL_I1:%.*]] = extractelement <2 x i32> [[VAL]], i32 1 | ||
; CHECK-NEXT: [[SRC_I0:%.*]] = extractelement <1 x <2 x i32>*> [[SRC:%.*]], i32 0 | ||
; CHECK-NEXT: [[SRC_I0_I0:%.*]] = bitcast <2 x i32>* [[SRC_I0]] to i32* | ||
; CHECK-NEXT: [[SRC_I0_I1:%.*]] = getelementptr i32, i32* [[SRC_I0_I0]], i32 1 | ||
; CHECK-NEXT: store i32 [[VAL_I0]], i32* [[SRC_I0_I0]], align 4 | ||
; CHECK-NEXT: store i32 [[VAL_I1]], i32* [[SRC_I0_I1]], align 4 | ||
; CHECK-NEXT: ret void | ||
; | ||
%1 = extractelement <1 x <2 x i32>*> %src, i32 0 | ||
store <2 x i32> %val, <2 x i32>* %1, align 4 | ||
ret void | ||
} |