[llvm] 7068c84 - [DAG] visitREM - use isAllOnesOrAllOnesSplat instead of isConstOrConstSplat
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 5 08:44:52 PDT 2022
Author: Simon Pilgrim
Date: 2022-07-05T16:44:31+01:00
New Revision: 7068c843d25447e5fc9b1c2a1f7d91275642cc24
URL: https://github.com/llvm/llvm-project/commit/7068c843d25447e5fc9b1c2a1f7d91275642cc24
DIFF: https://github.com/llvm/llvm-project/commit/7068c843d25447e5fc9b1c2a1f7d91275642cc24.diff
LOG: [DAG] visitREM - use isAllOnesOrAllOnesSplat instead of isConstOrConstSplat
We were only using the N1C scalar/splat value once, so for clarity use isAllOnesOrAllOnesSplat instead if we actually need it.
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index dbb81ab65ebb..07b237f7436f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -4552,13 +4552,12 @@ SDValue DAGCombiner::visitREM(SDNode *N) {
SDLoc DL(N);
// fold (rem c1, c2) -> c1%c2
- ConstantSDNode *N1C = isConstOrConstSplat(N1);
if (SDValue C = DAG.FoldConstantArithmetic(Opcode, DL, VT, {N0, N1}))
return C;
// fold (urem X, -1) -> select(FX == -1, 0, FX)
// Freeze the numerator to avoid a miscompile with an undefined value.
- if (!isSigned && N1C && N1C->isAllOnes()) {
+ if (!isSigned && llvm::isAllOnesOrAllOnesSplat(N1, /*AllowUndefs*/ false)) {
SDValue F0 = DAG.getFreeze(N0);
SDValue EqualsNeg1 = DAG.getSetCC(DL, CCVT, F0, N1, ISD::SETEQ);
return DAG.getSelect(DL, VT, EqualsNeg1, DAG.getConstant(0, DL, VT), F0);
More information about the llvm-commits
mailing list