Skip to content

[PowerPC] Fix assert exposed by PR 95931 in LowerBITCAST #108062

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 3 commits into from
Sep 10, 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
9 changes: 5 additions & 4 deletions llvm/lib/Target/PowerPC/PPCISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9470,12 +9470,13 @@ SDValue PPCTargetLowering::LowerBITCAST(SDValue Op, SelectionDAG &DAG) const {
SDLoc dl(Op);
SDValue Op0 = Op->getOperand(0);

if (!Subtarget.isPPC64() || (Op0.getOpcode() != ISD::BUILD_PAIR) ||
(Op.getValueType() != MVT::f128))
return SDValue();

SDValue Lo = Op0.getOperand(0);
SDValue Hi = Op0.getOperand(1);

if ((Op.getValueType() != MVT::f128) ||
(Op0.getOpcode() != ISD::BUILD_PAIR) || (Lo.getValueType() != MVT::i64) ||
(Hi.getValueType() != MVT::i64) || !Subtarget.isPPC64())
if ((Lo.getValueType() != MVT::i64) || (Hi.getValueType() != MVT::i64))
return SDValue();

if (!Subtarget.isLittleEndian())
Expand Down
22 changes: 22 additions & 0 deletions llvm/test/CodeGen/PowerPC/f128-bitcast.ll
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,25 @@ entry:
ret i64 %1
}

define <4 x i32> @truncBitcast(i512 %a) {
; CHECK-LABEL: truncBitcast:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: mtvsrdd v2, r4, r3
; CHECK-NEXT: blr
;
; CHECK-BE-LABEL: truncBitcast:
; CHECK-BE: # %bb.0: # %entry
; CHECK-BE-NEXT: mtvsrdd v2, r9, r10
; CHECK-BE-NEXT: blr
;
; CHECK-P8-LABEL: truncBitcast:
; CHECK-P8: # %bb.0: # %entry
; CHECK-P8-NEXT: mtfprd f0, r3
; CHECK-P8-NEXT: mtfprd f1, r4
; CHECK-P8-NEXT: xxmrghd v2, vs1, vs0
; CHECK-P8-NEXT: blr
entry:
%0 = trunc i512 %a to i128
%1 = bitcast i128 %0 to <4 x i32>
ret <4 x i32> %1
}
Loading