<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Feb 1, 2011, at 1:06 AM, Duncan Sands wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">Author: baldrick<br>Date: Tue Feb  1 03:06:20 2011<br>New Revision: 124657<br><br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=124657&view=rev">http://llvm.org/viewvc/llvm-project?rev=124657&view=rev</a><br>Log:<br>Add a m_Undef pattern for convenience.  This is so that code that uses<br>pattern matching can also pattern match undef, creating a more uniform<br>style.</span></blockquote></div><br><div>Nice.  FWIW, I verified that we get good code for both idioms:</div><div><br></div><div><div>bool foo(Value *V) { </div><div>  return isa<UndefValue>(V);</div><div>} </div><div><br></div><div>bool foo2(Value *V) {</div><div>return match(V, m_Undef());</div><div>}</div></div><div><br></div><div>both compile into:</div><div><br></div><div><div>define zeroext i1 @_Z4foo2PN4llvm5ValueE(%"class.llvm::Value"* nocapture %V) nounwind readonly ssp {</div><div>entry:</div><div>  %tmp.i.i.i.i.i.i.i.i.i = getelementptr inbounds %"class.llvm::Value"* %V, i64 0, i32 1</div><div>  %tmp2.i.i.i.i.i.i.i.i.i = load i8* %tmp.i.i.i.i.i.i.i.i.i, align 1, !tbaa !0</div><div>  %cmp.i.i.i.i.i.i.i.i = icmp eq i8 %tmp2.i.i.i.i.i.i.i.i.i, 5</div><div>  ret i1 %cmp.i.i.i.i.i.i.i.i</div><div>}</div></div><div><br></div><div>-Chris</div></body></html>