Skip to content

Commit 7e4c6e9

Browse files
authored
[SystemZ] Bugfix in getDemandedSrcElements(). (#88623)
For the intrinsic s390_vperm, all of the elements are demanded, so use an APInt with the value of '-1' for them (not '1'). Fixes #88397
1 parent a3ce29f commit 7e4c6e9

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

llvm/lib/Target/SystemZ/SystemZISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7818,7 +7818,7 @@ static APInt getDemandedSrcElements(SDValue Op, const APInt &DemandedElts,
78187818
break;
78197819
}
78207820
case Intrinsic::s390_vperm:
7821-
SrcDemE = APInt(NumElts, 1);
7821+
SrcDemE = APInt(NumElts, -1);
78227822
break;
78237823
default:
78247824
llvm_unreachable("Unhandled intrinsic.");

llvm/test/CodeGen/SystemZ/knownbits-intrinsics-binop.ll

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,3 +458,22 @@ define <16 x i8> @f30() {
458458
i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
459459
ret <16 x i8> %res
460460
}
461+
462+
; Test VPERM with various constant operands.
463+
define i32 @f31() {
464+
; CHECK-LABEL: f31:
465+
; CHECK-LABEL: # %bb.0:
466+
; CHECK-NEXT: larl %r1, .LCPI31_0
467+
; CHECK-NEXT: vl %v0, 0(%r1), 3
468+
; CHECK-NEXT: larl %r1, .LCPI31_1
469+
; CHECK-NEXT: vl %v1, 0(%r1), 3
470+
; CHECK-NEXT: vperm %v0, %v1, %v1, %v0
471+
; CHECK-NEXT: vlgvb %r2, %v0, 0
472+
; CHECK-NEXT: nilf %r2, 7
473+
; CHECK-NEXT: # kill: def $r2l killed $r2l killed $r2d
474+
; CHECK-NEXT: br %r14
475+
%P = tail call <16 x i8> @llvm.s390.vperm(<16 x i8> <i8 0, i8 1, i8 1, i8 2, i8 1, i8 2, i8 2, i8 3, i8 1, i8 2, i8 2, i8 3, i8 2, i8 3, i8 3, i8 4>, <16 x i8> <i8 0, i8 1, i8 1, i8 2, i8 1, i8 2, i8 2, i8 3, i8 1, i8 2, i8 2, i8 3, i8 2, i8 3, i8 3, i8 4>, <16 x i8> <i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15, i8 0>)
476+
%E = extractelement <16 x i8> %P, i64 0
477+
%res = zext i8 %E to i32
478+
ret i32 %res
479+
}

0 commit comments

Comments
 (0)