<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">David, <div><br></div><div>I am really happy to see that you are working on this. As part of the discussions on replacing SelectionDAG with something new, a few people mentioned that it would be much easier to migrate to a new infrastructure if the patterns were written in patterns such as the ones that you are proposing.  I like your approach. I look forward to seeing the complete patch. </div><div><br></div><div>Thanks,</div><div>Nadav</div><div><br><div><div>On Jul 20, 2013, at 6:48 PM, David Majnemer <<a href="mailto:david.majnemer@gmail.com">david.majnemer@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: Helvetica; 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;"><div dir="ltr"><div>I'd like to propose a PatternMatch-like interface for SelectionDAG.</div><div><br></div><div>I have a simple implementation attached, it matches on SDValue types and provides a convenience overload for SDNodes.</div><div><br></div><div>Currently, it uses similar names to PattternMatch.h (match, m_And, etc.).</div><div>I don't really care about the names but I figured to start with something familiar. They shouldn't conflict because they would both exist in their own namespaces.</div><div><br></div><div>The effect is pretty nice on some DAGCombiner code:</div><div><br></div><div>   // (or (and X, C1), (and Y, C2))  -> (and (or X, Y), C3) if possible.</div><div>   if (N0.getOpcode() == ISD::AND &&</div><div>       N1.getOpcode() == ISD::AND &&</div><div>       N0.getOperand(1).getOpcode() == ISD::Constant &&</div><div>       N1.getOperand(1).getOpcode() == ISD::Constant &&</div><div>       // Don't increase # computations.<br></div><div>       (N0.getNode()->hasOneUse() || N1.getNode()->hasOneUse())) {</div><div>     const APInt &LHSMask =</div><div>       cast<ConstantSDNode>(N0.getOperand(1))->getAPIntValue();</div><div>     const APInt &RHSMask =</div><div>       cast<ConstantSDNode>(N1.getOperand(1))->getAPIntValue();</div><div><br></div><div>becomes:</div><div>   const APInt *LHSMask, *RHSMask;</div><div>   if (match(N0, m_And(m_Value(), m_APInt(LHSMask))) &&<br></div><div>       match(N1, m_And(m_Value(), m_APInt(RHSMask))) &&<br></div><div>       // Don't increase # computations.<br></div><div>       (match(N0, m_OneUse()) || match(N1, m_OneUse()))) {</div><div><br></div><div>Note that the attached implementation is pretty incomplete, I just wanted a proof of concept before I run off and flesh it out further.</div><div><br></div><div>Thanks</div><div><br></div><div>-- </div><div>David Majnemer</div></div><span><ns.h></span>_______________________________________________<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></div></body></html>