[llvm-commits] [llvm] r124657 - in /llvm/trunk: include/llvm/Support/PatternMatch.h lib/Analysis/InstructionSimplify.cpp

Chris Lattner clattner at apple.com
Wed Feb 2 10:44:58 PST 2011


On Feb 1, 2011, at 1:06 AM, Duncan Sands wrote:

> Author: baldrick
> Date: Tue Feb  1 03:06:20 2011
> New Revision: 124657
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=124657&view=rev
> Log:
> Add a m_Undef pattern for convenience.  This is so that code that uses
> pattern matching can also pattern match undef, creating a more uniform
> style.

Nice.  FWIW, I verified that we get good code for both idioms:

bool foo(Value *V) { 
  return isa<UndefValue>(V);
} 

bool foo2(Value *V) {
return match(V, m_Undef());
}

both compile into:

define zeroext i1 @_Z4foo2PN4llvm5ValueE(%"class.llvm::Value"* nocapture %V) nounwind readonly ssp {
entry:
  %tmp.i.i.i.i.i.i.i.i.i = getelementptr inbounds %"class.llvm::Value"* %V, i64 0, i32 1
  %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
  %cmp.i.i.i.i.i.i.i.i = icmp eq i8 %tmp2.i.i.i.i.i.i.i.i.i, 5
  ret i1 %cmp.i.i.i.i.i.i.i.i
}

-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110202/16a35b01/attachment.html>


More information about the llvm-commits mailing list