diff options
| author | Nirav Dave <niravd@google.com> | 2017-07-18 19:49:20 +0000 |
|---|---|---|
| committer | Nirav Dave <niravd@google.com> | 2017-07-18 19:49:20 +0000 |
| commit | 041b87758a3cb279772d9f771ea343f057e72b4d (patch) | |
| tree | 0838b9a55d77a16c807e7cede15e4bf2aec91c35 | |
| parent | 95e45f9f93d1c605d04a842608c82ffa4ea395c9 (diff) | |
| download | bcm5719-llvm-041b87758a3cb279772d9f771ea343f057e72b4d.tar.gz bcm5719-llvm-041b87758a3cb279772d9f771ea343f057e72b4d.zip | |
[DAG] Reverse node replacement in extension operation. NFCI.
Reorder replacements to be user first in preparation for multi-level
folding to premptively avoid inadvertantly deleting later nodes from
sharing found from replacement.
llvm-svn: 308348
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index f2ecdbe253e..9058122c973 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -7172,11 +7172,13 @@ SDValue DAGCombiner::visitSIGN_EXTEND(SDNode *N) { N0.getValueType(), ExtLoad); ExtendSetCCUses(SetCCs, Trunc, ExtLoad, DL, ISD::SIGN_EXTEND); // If the load value is used only by N, replace it via CombineTo N. - if (N0.getValue(0).hasOneUse()) + bool NoReplaceTrunc = SDValue(LN0, 0).hasOneUse(); + CombineTo(N, ExtLoad); + if (NoReplaceTrunc) DAG.ReplaceAllUsesOfValueWith(SDValue(LN0, 1), ExtLoad.getValue(1)); else CombineTo(LN0, Trunc, ExtLoad.getValue(1)); - return CombineTo(N, ExtLoad); // Return N so it doesn't get rechecked! + return SDValue(N, 0); } } @@ -7233,12 +7235,13 @@ SDValue DAGCombiner::visitSIGN_EXTEND(SDNode *N) { SDLoc(N0.getOperand(0)), N0.getOperand(0).getValueType(), ExtLoad); ExtendSetCCUses(SetCCs, Trunc, ExtLoad, DL, ISD::SIGN_EXTEND); - // If the load value is used only by N, replace it via CombineTo N. - if (SDValue(LN0, 0).hasOneUse()) + bool NoReplaceTrunc = SDValue(LN0, 0).hasOneUse(); + CombineTo(N, And); + if (NoReplaceTrunc) DAG.ReplaceAllUsesOfValueWith(SDValue(LN0, 1), ExtLoad.getValue(1)); else CombineTo(LN0, Trunc, ExtLoad.getValue(1)); - return CombineTo(N, And); // Return N so it doesn't get rechecked! + return SDValue(N,0); // Return N so it doesn't get rechecked! } } } @@ -7479,11 +7482,13 @@ SDValue DAGCombiner::visitZERO_EXTEND(SDNode *N) { N0.getValueType(), ExtLoad); ExtendSetCCUses(SetCCs, Trunc, ExtLoad, SDLoc(N), ISD::ZERO_EXTEND); // If the load value is used only by N, replace it via CombineTo N. - if (SDValue(LN0, 0).hasOneUse()) + bool NoReplaceTrunc = SDValue(LN0, 0).hasOneUse(); + CombineTo(N, ExtLoad); + if (NoReplaceTrunc) DAG.ReplaceAllUsesOfValueWith(SDValue(LN0, 1), ExtLoad.getValue(1)); else CombineTo(LN0, Trunc, ExtLoad.getValue(1)); - return CombineTo(N, ExtLoad); // Return N so it doesn't get rechecked! + return SDValue(N, 0); // Return N so it doesn't get rechecked! } } @@ -7534,12 +7539,13 @@ SDValue DAGCombiner::visitZERO_EXTEND(SDNode *N) { SDLoc(N0.getOperand(0)), N0.getOperand(0).getValueType(), ExtLoad); ExtendSetCCUses(SetCCs, Trunc, ExtLoad, DL, ISD::ZERO_EXTEND); - // If the load value is used only by N, replace it via CombineTo N. - if (SDValue(LN0, 0).hasOneUse()) + bool NoReplaceTrunc = SDValue(LN0, 0).hasOneUse(); + CombineTo(N, And); + if (NoReplaceTrunc) DAG.ReplaceAllUsesOfValueWith(SDValue(LN0, 1), ExtLoad.getValue(1)); else CombineTo(LN0, Trunc, ExtLoad.getValue(1)); - return CombineTo(N, And); // Return N so it doesn't get rechecked! + return SDValue(N,0); // Return N so it doesn't get rechecked! } } } @@ -7716,11 +7722,13 @@ SDValue DAGCombiner::visitANY_EXTEND(SDNode *N) { ExtendSetCCUses(SetCCs, Trunc, ExtLoad, SDLoc(N), ISD::ANY_EXTEND); // If the load value is used only by N, replace it via CombineTo N. - if (N0.hasOneUse()) + bool NoReplaceTrunc = N0.hasOneUse(); + CombineTo(N, ExtLoad); + if (NoReplaceTrunc) DAG.ReplaceAllUsesOfValueWith(SDValue(LN0, 1), ExtLoad.getValue(1)); else CombineTo(LN0, Trunc, ExtLoad.getValue(1)); - return CombineTo(N, ExtLoad); // Return N so it doesn't get rechecked! + return SDValue(N, 0); // Return N so it doesn't get rechecked! } } |

