[llvm] r301258 - [DAGCombiner] Use APInt::intersects to avoid tmp variable. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 24 14:43:21 PDT 2017
Author: rksimon
Date: Mon Apr 24 16:43:21 2017
New Revision: 301258
URL: http://llvm.org/viewvc/llvm-project?rev=301258&view=rev
Log:
[DAGCombiner] Use APInt::intersects to avoid tmp variable. NFCI.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=301258&r1=301257&r2=301258&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Apr 24 16:43:21 2017
@@ -4200,12 +4200,13 @@ SDValue DAGCombiner::visitOR(SDNode *N)
// reassociate or
if (SDValue ROR = ReassociateOps(ISD::OR, SDLoc(N), N0, N1))
return ROR;
+
// Canonicalize (or (and X, c1), c2) -> (and (or X, c2), c1|c2)
// iff (c1 & c2) != 0.
if (N1C && N0.getOpcode() == ISD::AND && N0.getNode()->hasOneUse() &&
isa<ConstantSDNode>(N0.getOperand(1))) {
ConstantSDNode *C1 = cast<ConstantSDNode>(N0.getOperand(1));
- if ((C1->getAPIntValue() & N1C->getAPIntValue()) != 0) {
+ if (C1->getAPIntValue().intersects(N1C->getAPIntValue())) {
if (SDValue COR = DAG.FoldConstantArithmetic(ISD::OR, SDLoc(N1), VT,
N1C, C1))
return DAG.getNode(
@@ -4214,6 +4215,7 @@ SDValue DAGCombiner::visitOR(SDNode *N)
return SDValue();
}
}
+
// Simplify: (or (op x...), (op y...)) -> (op (or x, y))
if (N0.getOpcode() == N1.getOpcode())
if (SDValue Tmp = SimplifyBinOpWithSameOpcodeHands(N))
More information about the llvm-commits
mailing list