This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombine] Generalize the case (add (or x, c1), c2) -> (add x, (c1 + c2))
ClosedPublic

Authored by hliao on Jun 11 2020, 7:05 PM.

Diff Detail

Event Timeline

hliao created this revision.Jun 11 2020, 7:05 PM
craig.topper added inline comments.
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
2189–2190

Update the comment.

lebedev.ri added a subscriber: lebedev.ri.
lebedev.ri added inline comments.
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
2192

I strongly suspect you need , /* NoOpaque */ true here, else folding can fail.

RKSimon added inline comments.Jun 12 2020, 2:02 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
2196

Probably safer to assume FoldConstantArithmetic can fail:

if (SDValue Add0 = DAG.FoldConstantArithmetic(ISD::ADD, DL, VT, {N1, N0.getOperand(1)}))
  return DAG.getNode(ISD::ADD, DL, VT, N0.getOperand(0), Add0);
lenary removed a subscriber: lenary.Jun 12 2020, 3:25 AM
hliao updated this revision to Diff 270403.Jun 12 2020, 7:58 AM

Revise the original comment.

hliao updated this revision to Diff 270409.Jun 12 2020, 8:23 AM

Revise again

hliao marked 3 inline comments as done.Jun 12 2020, 8:24 AM
This revision is now accepted and ready to land.Jun 12 2020, 9:00 AM
This revision was automatically updated to reflect the committed changes.