aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2021-11-10 15:16:27 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2021-11-10 15:19:13 +0000
commit381d14775e2002f2eeefd96fb73bd8fd935e0fd2 (patch)
tree377e5f9feeb11cd5d2c254afb8a3a0a346b79943
parentea53a6938b12894dc883b85cf86da03ecec01b0f (diff)
downloadllvm-381d14775e2002f2eeefd96fb73bd8fd935e0fd2.zip
llvm-381d14775e2002f2eeefd96fb73bd8fd935e0fd2.tar.gz
llvm-381d14775e2002f2eeefd96fb73bd8fd935e0fd2.tar.bz2
[DAG] reassociateOpsCommutative - pull out repeated getOperand() calls. NFC.
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index bf4b418..be52fd2 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -1063,21 +1063,23 @@ SDValue DAGCombiner::reassociateOpsCommutative(unsigned Opc, const SDLoc &DL,
if (N0.getOpcode() != Opc)
return SDValue();
- if (DAG.isConstantIntBuildVectorOrConstantInt(N0.getOperand(1))) {
+ SDValue N00 = N0.getOperand(0);
+ SDValue N01 = N0.getOperand(1);
+
+ if (DAG.isConstantIntBuildVectorOrConstantInt(N01)) {
if (DAG.isConstantIntBuildVectorOrConstantInt(N1)) {
// Reassociate: (op (op x, c1), c2) -> (op x, (op c1, c2))
- if (SDValue OpNode =
- DAG.FoldConstantArithmetic(Opc, DL, VT, {N0.getOperand(1), N1}))
- return DAG.getNode(Opc, DL, VT, N0.getOperand(0), OpNode);
+ if (SDValue OpNode = DAG.FoldConstantArithmetic(Opc, DL, VT, {N01, N1}))
+ return DAG.getNode(Opc, DL, VT, N00, OpNode);
return SDValue();
}
if (N0.hasOneUse()) {
// Reassociate: (op (op x, c1), y) -> (op (op x, y), c1)
// iff (op x, c1) has one use
- SDValue OpNode = DAG.getNode(Opc, SDLoc(N0), VT, N0.getOperand(0), N1);
+ SDValue OpNode = DAG.getNode(Opc, SDLoc(N0), VT, N00, N1);
if (!OpNode.getNode())
return SDValue();
- return DAG.getNode(Opc, DL, VT, OpNode, N0.getOperand(1));
+ return DAG.getNode(Opc, DL, VT, OpNode, N01);
}
}
return SDValue();