summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2010-11-17 18:52:15 +0000
committerDuncan Sands <baldrick@free.fr>2010-11-17 18:52:15 +0000
commit2b749870d0488c3b049edf5d0c8875f56f5b1bed (patch)
tree18afe3a1c1876a3a43e139d1b39e2e54ec780f60 /include
parent89e14c7579d9351da2e39a85703882bac3a83980 (diff)
downloadexternal_llvm-2b749870d0488c3b049edf5d0c8875f56f5b1bed.zip
external_llvm-2b749870d0488c3b049edf5d0c8875f56f5b1bed.tar.gz
external_llvm-2b749870d0488c3b049edf5d0c8875f56f5b1bed.tar.bz2
Move some those Xor simplifications which don't require creating new
instructions out of InstCombine and into InstructionSimplify. While there, introduce an m_AllOnes pattern to simplify matching with integers and vectors with all bits equal to one. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119536 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Analysis/InstructionSimplify.h5
-rw-r--r--include/llvm/Support/PatternMatch.h16
2 files changed, 20 insertions, 1 deletions
diff --git a/include/llvm/Analysis/InstructionSimplify.h b/include/llvm/Analysis/InstructionSimplify.h
index 965e71b..f88fc46 100644
--- a/include/llvm/Analysis/InstructionSimplify.h
+++ b/include/llvm/Analysis/InstructionSimplify.h
@@ -37,6 +37,11 @@ namespace llvm {
Value *SimplifyOrInst(Value *LHS, Value *RHS, const TargetData *TD = 0,
const DominatorTree *DT = 0);
+ /// SimplifyXorInst - Given operands for a Xor, see if we can
+ /// fold the result. If not, this returns null.
+ Value *SimplifyXorInst(Value *LHS, Value *RHS, const TargetData *TD = 0,
+ const DominatorTree *DT = 0);
+
/// SimplifyICmpInst - Given operands for an ICmpInst, see if we can
/// fold the result. If not, this returns null.
Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h
index bee6768..8b58121 100644
--- a/include/llvm/Support/PatternMatch.h
+++ b/include/llvm/Support/PatternMatch.h
@@ -96,9 +96,23 @@ struct one_ty {
}
};
-/// m_One() - Match a an integer 1.
+/// m_One() - Match an integer 1.
inline one_ty m_One() { return one_ty(); }
+struct all_ones_ty {
+ template<typename ITy>
+ bool match(ITy *V) {
+ if (const ConstantInt *C = dyn_cast<ConstantInt>(V))
+ return C->isAllOnesValue();
+ if (const ConstantVector *C = dyn_cast<ConstantVector>(V))
+ return C->isAllOnesValue();
+ return false;
+ }
+};
+
+/// m_AllOnes() - Match an integer or vector with all bits set to true.
+inline all_ones_ty m_AllOnes() { return all_ones_ty(); }
+
template<typename Class>
struct bind_ty {