Skip to content

Commit

Permalink
[DAGCombiner] Simplify code around call to reduceLoadWidth in visitAN…
Browse files Browse the repository at this point in the history
…D. NFC

We were looking for loads or any_extend+load. reduceLoadWidth
hasn't known how to look through such an any_extend to find the
load since D40667 almost 5 years ago.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D130333
  • Loading branch information
topperc committed Jul 22, 2022
1 parent d7bf81f commit be208b4
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Expand Up @@ -6363,18 +6363,9 @@ SDValue DAGCombiner::visitAND(SDNode *N) {

// fold (and (load x), 255) -> (zextload x, i8)
// fold (and (extload x, i16), 255) -> (zextload x, i8)
// fold (and (any_ext (extload x, i16)), 255) -> (zextload x, i8)
if (!VT.isVector() && N1C && (N0.getOpcode() == ISD::LOAD ||
(N0.getOpcode() == ISD::ANY_EXTEND &&
N0.getOperand(0).getOpcode() == ISD::LOAD))) {
if (SDValue Res = reduceLoadWidth(N)) {
LoadSDNode *LN0 = N0->getOpcode() == ISD::ANY_EXTEND
? cast<LoadSDNode>(N0.getOperand(0)) : cast<LoadSDNode>(N0);
AddToWorklist(N);
DAG.ReplaceAllUsesOfValueWith(SDValue(LN0, 0), Res);
return SDValue(N, 0);
}
}
if (N1C && N0.getOpcode() == ISD::LOAD && !VT.isVector())
if (SDValue Res = reduceLoadWidth(N))
return Res;

if (LegalTypes) {
// Attempt to propagate the AND back up to the leaves which, if they're
Expand Down

0 comments on commit be208b4

Please sign in to comment.