Skip to content

Fix for logic in combineExtract() #108208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7361,8 +7361,9 @@ SDValue SystemZTargetLowering::combineEXTRACT_VECTOR_ELT(
if (auto *IndexN = dyn_cast<ConstantSDNode>(N->getOperand(1))) {
SDValue Op0 = N->getOperand(0);
EVT VecVT = Op0.getValueType();
return combineExtract(SDLoc(N), N->getValueType(0), VecVT, Op0,
IndexN->getZExtValue(), DCI, false);
if (canTreatAsByteVector(VecVT))
return combineExtract(SDLoc(N), N->getValueType(0), VecVT, Op0,
IndexN->getZExtValue(), DCI, false);
}
return SDValue();
}
Expand Down
20 changes: 20 additions & 0 deletions llvm/test/CodeGen/SystemZ/DAGCombine_extract_vector_elt.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; RUN: llc -mtriple=s390x-linux-gnu -mcpu=z16 < %s | FileCheck %s
;
; Check that DAGCombiner doesn't crash in SystemZ combineExtract()
; when handling EXTRACT_VECTOR_ELT with a vector of i1:s.

define i32 @fun(i32 %arg) {
; CHECK-LABEL: fun:
entry:
%cc = icmp eq i32 %arg, 0
br label %loop

loop:
%P = phi <128 x i1> [ zeroinitializer, %entry ], [ bitcast (<2 x i64> <i64 3, i64 3> to <128 x i1>), %loop ]
br i1 %cc, label %exit, label %loop

exit:
%E = extractelement <128 x i1> %P, i64 0
%Res = zext i1 %E to i32
ret i32 %Res
}
Loading