<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Sep 23, 2014, at 6:05 PM, Jan Vesely <<a href="mailto:jan.vesely@rutgers.edu">jan.vesely@rutgers.edu</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Tue, 2014-09-23 at 15:21 -0400, Chad Rosier wrote:<br><blockquote type="cite">Testcase?<br></blockquote><br>I'm not sure how to add one. The situation is tested in<br>test/Transforms/InstCombine/sub.ll (test4) and indeed "opt -instcombine"<br>work even without the patch.<br>Is there a way to test DAGCombiner in a similar (generic) way, or do I<br>need to add a backend specific test?<br></div></blockquote><div><br></div><div>You usually need to add a target specific test for these kinds of things</div><br><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br>It's not clear to me why the instcombine and DAG combine nedd both to do<br>this kind of optimization.<br></div></blockquote><div><br></div><div>There are lots of reasons this pattern would only be exposed during instruction selection, such as if a target custom lowered an operation which emitted this pattern</div><div><br></div><br><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br>jan<br><br><blockquote type="cite"><br><blockquote type="cite">Signed-off-by: Jan Vesely <<a href="mailto:jan.vesely@rutgers.edu">jan.vesely@rutgers.edu</a>><br>---<br>lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 4 ++++<br>1 file changed, 4 insertions(+)<br><br>diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp<br>b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp<br>index 33e7059..bc39fe3 100644<br>--- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp<br>+++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp<br>@@ -1794,6 +1794,10 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {<br>  // fold (A+B)-B -> A<br>  if (N0.getOpcode() == ISD::ADD && N0.getOperand(1) == N1)<br>    return N0.getOperand(0);<br>+  // fold (A - (0-B)) -> A+B<br>+  if (N1.getOpcode() == ISD::SUB && isa<ConstantSDNode>(N1.getOperand(0))<br>&&<br>+      cast<ConstantSDNode>(N1.getOperand(0))->isNullValue())<br>+    return DAG.getNode(ISD::ADD, SDLoc(N), VT, N0, N1.getOperand(1));<br>  // fold C2-(A+C1) -> (C2-C1)-A<br>  if (N1.getOpcode() == ISD::ADD && N0C && N1C1) {<br>    SDValue NewC = DAG.getConstant(N0C->getAPIntValue() -<br>N1C1->getAPIntValue(),<br>--<br>1.9.3<br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br><br></blockquote><br><br></blockquote><br>--<span class="Apple-converted-space"> </span><br>Jan Vesely <<a href="mailto:jan.vesely@rutgers.edu">jan.vesely@rutgers.edu</a>><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></div></blockquote></div><br></body></html>