[llvm] ae8b10e - [DAG] (style) Break apart if-else chain as they all return
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sun May 1 09:57:08 PDT 2022
Author: Simon Pilgrim
Date: 2022-05-01T17:56:59+01:00
New Revision: ae8b10e5439c08e478a72d34d654a02c087bdc69
URL: https://github.com/llvm/llvm-project/commit/ae8b10e5439c08e478a72d34d654a02c087bdc69
DIFF: https://github.com/llvm/llvm-project/commit/ae8b10e5439c08e478a72d34d654a02c087bdc69.diff
LOG: [DAG] (style) Break apart if-else chain as they all return
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 13ea53723ebef..e139cf6268061 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -10973,17 +10973,18 @@ SDValue DAGCombiner::visitSELECT_CC(SDNode *N) {
CC, SDLoc(N), false)) {
AddToWorklist(SCC.getNode());
- if (ConstantSDNode *SCCC = dyn_cast<ConstantSDNode>(SCC.getNode())) {
- if (!SCCC->isZero())
- return N2; // cond always true -> true val
- else
- return N3; // cond always false -> false val
- } else if (SCC->isUndef()) {
- // When the condition is UNDEF, just return the first operand. This is
- // coherent the DAG creation, no setcc node is created in this case
+ // cond always true -> true val
+ // cond always false -> false val
+ if (auto *SCCC = dyn_cast<ConstantSDNode>(SCC.getNode()))
+ return SCCC->isZero() ? N3 : N2;
+
+ // When the condition is UNDEF, just return the first operand. This is
+ // coherent the DAG creation, no setcc node is created in this case
+ if (SCC->isUndef())
return N2;
- } else if (SCC.getOpcode() == ISD::SETCC) {
- // Fold to a simpler select_cc
+
+ // Fold to a simpler select_cc
+ if (SCC.getOpcode() == ISD::SETCC) {
SDValue SelectOp = DAG.getNode(
ISD::SELECT_CC, SDLoc(N), N2.getValueType(), SCC.getOperand(0),
SCC.getOperand(1), N2, N3, SCC.getOperand(2));
More information about the llvm-commits
mailing list