[llvm] [PowerPC] eliminate RLWINM instruction following LBARX as possible (PR #144089)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 19 12:05:39 PDT 2025
================
@@ -4961,6 +4961,21 @@ bool PPCDAGToDAGISel::tryAsSingleRLWINM(SDNode *N) {
// If this is just a masked value where the input is not handled, and
// is not a rotate-left (handled by a pattern in the .td file), emit rlwinm
if (isRunOfOnes(Imm, MB, ME) && Val.getOpcode() != ISD::ROTL) {
+ // The result of LBARX/LHARX do not need to be cleared as the instructions
+ // implicitly clear the upper bits.
+ unsigned AlreadyCleared = 0;
+ if (Val.getOpcode() == ISD::INTRINSIC_W_CHAIN) {
+ auto IntrinsicID = Val.getConstantOperandVal(1);
+ if (IntrinsicID == Intrinsic::ppc_lbarx)
+ AlreadyCleared = 24;
+ else if (IntrinsicID == Intrinsic::ppc_lharx)
+ AlreadyCleared = 16;
+ if (AlreadyCleared != 0 && AlreadyCleared == MB) {
----------------
RolandF77 wrote:
Don't you also have to know that ME is 31? Otherwise it clears bits on the right as well.
https://github.com/llvm/llvm-project/pull/144089
More information about the llvm-commits
mailing list