diff options
author | Paul Walker <paul.walker@arm.com> | 2024-04-15 12:51:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-15 12:51:06 +0100 |
commit | 673da8c83413c4d1e7e76e1b52a2924e837e7221 (patch) | |
tree | 9aa01736e0e2f88625892f62cfb4b65cf0a94e61 /llvm/lib/Target/AArch64 | |
parent | 8095b9ce6bf5831a14c72028920708f38d13d0c3 (diff) | |
download | llvm-673da8c83413c4d1e7e76e1b52a2924e837e7221.zip llvm-673da8c83413c4d1e7e76e1b52a2924e837e7221.tar.gz llvm-673da8c83413c4d1e7e76e1b52a2924e837e7221.tar.bz2 |
[LLVM][CodeGen][AArch64] Remove bogus lowering of sve_while{gt/ge/hi/hs} intrinsics. (#88126)
When fed constant operands we try to lower WHILE intrinsics to PTRUE
using a fixed length pattern. This is not valid for the decrementing
variants of WHILE because they construct their result predicate vector
by traversing from high->low lanes whereas the incrementing variants and
PTRUE traverse from low->high lanes.
Whilst we can still utilise PTRUE by reversing its result I figure
replacing a single WHILE with multiple SVE instructions is likely
counterproductive.
Diffstat (limited to 'llvm/lib/Target/AArch64')
-rw-r--r-- | llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 80181a7..27dc79f 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -5035,8 +5035,8 @@ static inline SDValue getPTrue(SelectionDAG &DAG, SDLoc DL, EVT VT, DAG.getTargetConstant(Pattern, DL, MVT::i32)); } -static SDValue optimizeWhile(SDValue Op, SelectionDAG &DAG, bool IsSigned, - bool IsLess, bool IsEqual) { +static SDValue optimizeIncrementingWhile(SDValue Op, SelectionDAG &DAG, + bool IsSigned, bool IsEqual) { if (!isa<ConstantSDNode>(Op.getOperand(1)) || !isa<ConstantSDNode>(Op.getOperand(2))) return SDValue(); @@ -5044,12 +5044,9 @@ static SDValue optimizeWhile(SDValue Op, SelectionDAG &DAG, bool IsSigned, SDLoc dl(Op); APInt X = Op.getConstantOperandAPInt(1); APInt Y = Op.getConstantOperandAPInt(2); - APInt NumActiveElems; bool Overflow; - if (IsLess) - NumActiveElems = IsSigned ? Y.ssub_ov(X, Overflow) : Y.usub_ov(X, Overflow); - else - NumActiveElems = IsSigned ? X.ssub_ov(Y, Overflow) : X.usub_ov(Y, Overflow); + APInt NumActiveElems = + IsSigned ? Y.ssub_ov(X, Overflow) : Y.usub_ov(X, Overflow); if (Overflow) return SDValue(); @@ -5396,29 +5393,17 @@ SDValue AArch64TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, return SDValue(); } case Intrinsic::aarch64_sve_whilelo: - return optimizeWhile(Op, DAG, /*IsSigned=*/false, /*IsLess=*/true, - /*IsEqual=*/false); + return optimizeIncrementingWhile(Op, DAG, /*IsSigned=*/false, + /*IsEqual=*/false); case Intrinsic::aarch64_sve_whilelt: - return optimizeWhile(Op, DAG, /*IsSigned=*/true, /*IsLess=*/true, - /*IsEqual=*/false); + return optimizeIncrementingWhile(Op, DAG, /*IsSigned=*/true, + /*IsEqual=*/false); case Intrinsic::aarch64_sve_whilels: - return optimizeWhile(Op, DAG, /*IsSigned=*/false, /*IsLess=*/true, - /*IsEqual=*/true); + return optimizeIncrementingWhile(Op, DAG, /*IsSigned=*/false, + /*IsEqual=*/true); case Intrinsic::aarch64_sve_whilele: - return optimizeWhile(Op, DAG, /*IsSigned=*/true, /*IsLess=*/true, - /*IsEqual=*/true); - case Intrinsic::aarch64_sve_whilege: - return optimizeWhile(Op, DAG, /*IsSigned=*/true, /*IsLess=*/false, - /*IsEqual=*/true); - case Intrinsic::aarch64_sve_whilegt: - return optimizeWhile(Op, DAG, /*IsSigned=*/true, /*IsLess=*/false, - /*IsEqual=*/false); - case Intrinsic::aarch64_sve_whilehs: - return optimizeWhile(Op, DAG, /*IsSigned=*/false, /*IsLess=*/false, - /*IsEqual=*/true); - case Intrinsic::aarch64_sve_whilehi: - return optimizeWhile(Op, DAG, /*IsSigned=*/false, /*IsLess=*/false, - /*IsEqual=*/false); + return optimizeIncrementingWhile(Op, DAG, /*IsSigned=*/true, + /*IsEqual=*/true); case Intrinsic::aarch64_sve_sunpkhi: return DAG.getNode(AArch64ISD::SUNPKHI, dl, Op.getValueType(), Op.getOperand(1)); |