[llvm-branch-commits] [llvm-branch] r86008 - /llvm/branches/Apple/Leela/include/llvm/Support/IRBuilder.h

Bill Wendling isanbard at gmail.com
Tue Nov 3 21:30:03 PST 2009


Author: void
Date: Tue Nov  3 23:30:02 2009
New Revision: 86008

URL: http://llvm.org/viewvc/llvm-project?rev=86008&view=rev
Log:
$ svn merge -c 86006 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r86006 into '.':
U    include/llvm/Support/IRBuilder.h


Modified:
    llvm/branches/Apple/Leela/include/llvm/Support/IRBuilder.h

Modified: llvm/branches/Apple/Leela/include/llvm/Support/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/include/llvm/Support/IRBuilder.h?rev=86008&r1=86007&r2=86008&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/include/llvm/Support/IRBuilder.h (original)
+++ llvm/branches/Apple/Leela/include/llvm/Support/IRBuilder.h Tue Nov  3 23:30:02 2009
@@ -390,15 +390,21 @@
     return Insert(BinaryOperator::CreateAShr(LHS, RHS), Name);
   }
   Value *CreateAnd(Value *LHS, Value *RHS, const Twine &Name = "") {
-    if (Constant *LC = dyn_cast<Constant>(LHS))
-      if (Constant *RC = dyn_cast<Constant>(RHS))
+    if (Constant *RC = dyn_cast<Constant>(RHS)) {
+      if (isa<ConstantInt>(RC) && cast<ConstantInt>(RC)->isAllOnesValue())
+        return LHS;  // LHS & -1 -> LHS
+      if (Constant *LC = dyn_cast<Constant>(LHS))
         return Folder.CreateAnd(LC, RC);
+    }
     return Insert(BinaryOperator::CreateAnd(LHS, RHS), Name);
   }
   Value *CreateOr(Value *LHS, Value *RHS, const Twine &Name = "") {
-    if (Constant *LC = dyn_cast<Constant>(LHS))
-      if (Constant *RC = dyn_cast<Constant>(RHS))
+    if (Constant *RC = dyn_cast<Constant>(RHS)) {
+      if (RC->isNullValue())
+        return LHS;  // LHS | 0 -> LHS
+      if (Constant *LC = dyn_cast<Constant>(LHS))
         return Folder.CreateOr(LC, RC);
+    }
     return Insert(BinaryOperator::CreateOr(LHS, RHS), Name);
   }
   Value *CreateXor(Value *LHS, Value *RHS, const Twine &Name = "") {





More information about the llvm-branch-commits mailing list