Skip to content

Commit 8f8e444

Browse files
committed
Simplify LShr construction; add AArch64/PowerPC tests
1 parent 1e1ef6c commit 8f8e444

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,8 +2021,7 @@ bool VectorCombine::scalarizeExtExtract(Instruction &I) {
20212021
uint64_t ShiftAmt = DL->isBigEndian()
20222022
? (TotalBits - SrcEltSizeInBits - Idx * SrcEltSizeInBits)
20232023
: (Idx * SrcEltSizeInBits);
2024-
Value *ShAmtVal = ConstantInt::get(PackedTy, ShiftAmt);
2025-
Value *LShr = Builder.CreateLShr(ScalarV, ShAmtVal);
2024+
Value *LShr = Builder.CreateLShr(ScalarV, ShiftAmt);
20262025
Value *And = Builder.CreateAnd(LShr, Mask);
20272026
U->replaceAllUsesWith(And);
20282027
}

llvm/test/Transforms/VectorCombine/scalarize-ext-extract-endian.ll renamed to llvm/test/Transforms/VectorCombine/AArch64/scalarize-ext-extract-endian.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; RUN: opt -passes='vector-combine,dce' -S -mtriple=aarch64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=LE
2-
; RUN: opt -passes='vector-combine,dce' -S -mtriple=powerpc64-ibm-aix-xcoff %s -o - | FileCheck %s --check-prefix=BE
2+
; RUN: opt -passes='vector-combine,dce' -S -mtriple=aarch64_be-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=BE
33

44
define i64 @g(<8 x i8> %v) {
55
%z = zext <8 x i8> %v to <8 x i64>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
; RUN: opt -passes='vector-combine,dce' -S -mtriple=aarch64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=LE
2+
; RUN: opt -passes='vector-combine,dce' -S -mtriple=powerpc64-ibm-aix-xcoff %s -o - | FileCheck %s --check-prefix=BE
3+
4+
define i64 @g(<8 x i8> %v) {
5+
%z = zext <8 x i8> %v to <8 x i64>
6+
%e0 = extractelement <8 x i64> %z, i32 0
7+
%e7 = extractelement <8 x i64> %z, i32 7
8+
%sum = add i64 %e0, %e7
9+
ret i64 %sum
10+
}
11+
12+
; LE-LABEL: @g(
13+
; LE: bitcast <8 x i8> %{{.*}} to i64
14+
; LE: lshr i64 %{{.*}}, 56
15+
; LE: and i64 %{{.*}}, 255
16+
; LE-NOT: extractelement
17+
18+
; BE-LABEL: @g(
19+
; BE: bitcast <8 x i8> %{{.*}} to i64
20+
; BE: and i64 %{{.*}}, 255
21+
; BE: lshr i64 %{{.*}}, 56
22+
; BE-NOT: extractelement
23+

0 commit comments

Comments
 (0)