Skip to content

Commit 5ad586c

Browse files
committed
[SLP] Fix isOpcodeOrAlt cannot find interchangeable instruction.
1 parent b7c1a24 commit 5ad586c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,8 +1035,7 @@ class InstructionsState {
10351035
bool isAltShuffle() const { return getMainOp() != getAltOp(); }
10361036

10371037
bool isOpcodeOrAlt(Instruction *I) const {
1038-
unsigned CheckedOpcode = I->getOpcode();
1039-
return getOpcode() == CheckedOpcode || getAltOpcode() == CheckedOpcode;
1038+
return isConvertible(I, MainOp, AltOp);
10401039
}
10411040

10421041
/// Checks if the current state is valid, i.e. has non-null MainOp

llvm/test/Transforms/SLPVectorizer/isOpcodeOrAlt.ll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
; RUN: opt -passes=slp-vectorizer -S -slp-max-reg-size=1024 %s | FileCheck %s
33

44
define void @test(ptr %a, ptr %b) {
5+
; CHECK-LABEL: @test(
6+
; CHECK-NEXT: entry:
7+
; CHECK-NEXT: [[GEP0:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 0
8+
; CHECK-NEXT: [[GEP4:%.*]] = getelementptr inbounds i32, ptr [[B:%.*]], i64 0
9+
; CHECK-NEXT: [[TMP0:%.*]] = load <4 x i32>, ptr [[GEP0]], align 4
10+
; CHECK-NEXT: [[TMP1:%.*]] = shl <4 x i32> [[TMP0]], <i32 1, i32 0, i32 1, i32 0>
11+
; CHECK-NEXT: [[TMP2:%.*]] = mul <4 x i32> [[TMP0]], <i32 1, i32 0, i32 1, i32 0>
12+
; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> [[TMP2]], <4 x i32> <i32 0, i32 1, i32 6, i32 3>
13+
; CHECK-NEXT: store <4 x i32> [[TMP3]], ptr [[GEP4]], align 4
14+
; CHECK-NEXT: ret void
15+
;
516
entry:
617
%gep0 = getelementptr inbounds i32, ptr %a, i64 0
718
%gep1 = getelementptr inbounds i32, ptr %a, i64 1

0 commit comments

Comments
 (0)