[llvm] [X86] Try to shrink signed i64 compares if the input has enough one bits (PR #149719)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 21 00:41:26 PDT 2025
================
@@ -23489,6 +23488,23 @@ static SDValue EmitCmp(SDValue Op0, SDValue Op1, X86::CondCode X86CC,
Op1 = DAG.getNode(ISD::TRUNCATE, dl, CmpVT, Op1);
}
+ // Try to shrink signed i64 compares if the input has enough one bits.
+ // Or the input is sign extended from a 32-bit value.
+ // TODO: Should we peek through freeze?
+ // TODO: Is SIGN_EXTEND_INREG needed here?
+ if (CmpVT == MVT::i64 && isX86CCSigned(X86CC) &&
+ Op0.hasOneUse() && // Hacky way to not break CSE opportunities with sub.
+ (DAG.ComputeNumSignBits(Op1) > 32 ||
+ Op1.getOpcode() == ISD::SIGN_EXTEND ||
----------------
RKSimon wrote:
Remove the SIGN_EXTEND/SIGN_EXTEND_INREG checks - ComputeNumSignBits will handle it properly (also the opcode checks don't checks what typesize you're extending from).
https://github.com/llvm/llvm-project/pull/149719
More information about the llvm-commits
mailing list