mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
[AArch64]Fix PR21675, a bug about lowering llvm.ctpop.i32. We should noot use "DAG.getUNDEF(MVT::v8i8)" to get all zero vector.
Patch by Wei-cheng Wang. llvm-svn: 227550
This commit is contained in:
parent
724dc848e4
commit
89352e7534
@ -3451,18 +3451,12 @@ SDValue AArch64TargetLowering::LowerCTPOP(SDValue Op, SelectionDAG &DAG) const {
|
||||
SDValue Val = Op.getOperand(0);
|
||||
SDLoc DL(Op);
|
||||
EVT VT = Op.getValueType();
|
||||
SDValue ZeroVec = DAG.getUNDEF(MVT::v8i8);
|
||||
|
||||
SDValue VecVal;
|
||||
if (VT == MVT::i32) {
|
||||
VecVal = DAG.getNode(ISD::BITCAST, DL, MVT::f32, Val);
|
||||
VecVal = DAG.getTargetInsertSubreg(AArch64::ssub, DL, MVT::v8i8, ZeroVec,
|
||||
VecVal);
|
||||
} else {
|
||||
VecVal = DAG.getNode(ISD::BITCAST, DL, MVT::v8i8, Val);
|
||||
}
|
||||
if (VT == MVT::i32)
|
||||
Val = DAG.getNode(ISD::ZERO_EXTEND, DL, MVT::i64, Val);
|
||||
Val = DAG.getNode(ISD::BITCAST, DL, MVT::v8i8, Val);
|
||||
|
||||
SDValue CtPop = DAG.getNode(ISD::CTPOP, DL, MVT::v8i8, VecVal);
|
||||
SDValue CtPop = DAG.getNode(ISD::CTPOP, DL, MVT::v8i8, Val);
|
||||
SDValue UaddLV = DAG.getNode(
|
||||
ISD::INTRINSIC_WO_CHAIN, DL, MVT::i32,
|
||||
DAG.getConstant(Intrinsic::aarch64_neon_uaddlv, MVT::i32), CtPop);
|
||||
|
@ -4,7 +4,8 @@
|
||||
define i32 @cnt32_advsimd(i32 %x) nounwind readnone {
|
||||
%cnt = tail call i32 @llvm.ctpop.i32(i32 %x)
|
||||
ret i32 %cnt
|
||||
; CHECK: fmov s0, w0
|
||||
; CHECK: ubfx x{{[0-9]+}}
|
||||
; CHECK: fmov d0, x{{[0-9]+}}
|
||||
; CHECK: cnt.8b v0, v0
|
||||
; CHECK: uaddlv.8b h0, v0
|
||||
; CHECK: fmov w0, s0
|
||||
@ -15,7 +16,24 @@ define i32 @cnt32_advsimd(i32 %x) nounwind readnone {
|
||||
; CHECK-NONEON: and w{{[0-9]+}}, w{{[0-9]+}}, #0x33333333
|
||||
; CHECK-NONEON: and w{{[0-9]+}}, w{{[0-9]+}}, #0xf0f0f0f
|
||||
; CHECK-NONEON: mul
|
||||
}
|
||||
|
||||
define i32 @cnt32_advsimd_2(<2 x i32> %x) {
|
||||
%1 = extractelement <2 x i32> %x, i64 0
|
||||
%2 = tail call i32 @llvm.ctpop.i32(i32 %1)
|
||||
ret i32 %2
|
||||
; CHECK: fmov w0, s0
|
||||
; CHECK: fmov d0, x0
|
||||
; CHECK: cnt.8b v0, v0
|
||||
; CHECK: uaddlv.8b h0, v0
|
||||
; CHECK: fmov w0, s0
|
||||
; CHECK: ret
|
||||
; CHECK-NONEON-LABEL: cnt32_advsimd_2
|
||||
; CHECK-NONEON-NOT: 8b
|
||||
; CHECK-NONEON: and w{{[0-9]+}}, w{{[0-9]+}}, #0x55555555
|
||||
; CHECK-NONEON: and w{{[0-9]+}}, w{{[0-9]+}}, #0x33333333
|
||||
; CHECK-NONEON: and w{{[0-9]+}}, w{{[0-9]+}}, #0xf0f0f0f
|
||||
; CHECK-NONEON: mul
|
||||
}
|
||||
|
||||
define i64 @cnt64_advsimd(i64 %x) nounwind readnone {
|
||||
|
Loading…
Reference in New Issue
Block a user