Skip to content

Commit ad3a0ae

Browse files
authored
[VectorCombine] foldSelectShuffle - early-out cases where the max vector register width isn't large enough (llvm#157430)
Technically this could happen with vector units that can't handle all legal scalar widths - but its good enough to use a generic crash test without a suitable target Fixes llvm#157335
1 parent 61a8d2d commit ad3a0ae

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3903,6 +3903,8 @@ bool VectorCombine::foldSelectShuffle(Instruction &I, bool FromReduction) {
39033903
unsigned MaxVectorSize =
39043904
TTI.getRegisterBitWidth(TargetTransformInfo::RGK_FixedWidthVector);
39053905
unsigned MaxElementsInVector = MaxVectorSize / ElementSize;
3906+
if (MaxElementsInVector == 0)
3907+
return false;
39063908
// When there are multiple shufflevector operations on the same input,
39073909
// especially when the vector length is larger than the register size,
39083910
// identical shuffle patterns may occur across different groups of elements.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt -passes=vector-combine -S %s | FileCheck %s
3+
4+
define <2 x double> @PR157335() {
5+
; CHECK-LABEL: @PR157335(
6+
; CHECK-NEXT: [[V0:%.*]] = fmul <2 x double> zeroinitializer, zeroinitializer
7+
; CHECK-NEXT: [[V1:%.*]] = fmul <2 x double> zeroinitializer, zeroinitializer
8+
; CHECK-NEXT: [[V2:%.*]] = fsub <2 x double> [[V0]], [[V1]]
9+
; CHECK-NEXT: [[V3:%.*]] = fadd <2 x double> [[V0]], [[V1]]
10+
; CHECK-NEXT: [[V4:%.*]] = shufflevector <2 x double> [[V2]], <2 x double> [[V3]], <2 x i32> <i32 0, i32 3>
11+
; CHECK-NEXT: ret <2 x double> [[V4]]
12+
;
13+
%v0 = fmul <2 x double> zeroinitializer, zeroinitializer
14+
%v1 = fmul <2 x double> zeroinitializer, zeroinitializer
15+
%v2 = fsub <2 x double> %v0, %v1
16+
%v3 = fadd <2 x double> %v0, %v1
17+
%v4 = shufflevector <2 x double> %v2, <2 x double> %v3, <2 x i32> <i32 0, i32 3>
18+
ret <2 x double> %v4
19+
}

0 commit comments

Comments
 (0)