[PATCH] D33585: [InstSimplify] Use commutable matchers to shorten some code
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 26 11:00:41 PDT 2017
craig.topper updated this revision to Diff 100434.
craig.topper added a comment.
Rebase on top of the patch to use m_APInt
https://reviews.llvm.org/D33585
Files:
lib/Analysis/InstructionSimplify.cpp
Index: lib/Analysis/InstructionSimplify.cpp
===================================================================
--- lib/Analysis/InstructionSimplify.cpp
+++ lib/Analysis/InstructionSimplify.cpp
@@ -1930,26 +1930,18 @@
// If we have: ((V + N) & C1) | (V & C2)
// .. and C2 = ~C1 and C2 is 0+1+ and (N & C2) == 0
// replace with V+N.
- Value *V1, *V2;
+ Value *N;
if (C2->isMask() && // C2 == 0+1+
- match(A, m_Add(m_Value(V1), m_Value(V2)))) {
+ match(A, m_Add(m_Specific(B), m_Value(N)))) {
// Add commutes, try both ways.
- if (V1 == B &&
- MaskedValueIsZero(V2, *C2, Q.DL, 0, Q.AC, Q.CxtI, Q.DT))
- return A;
- if (V2 == B &&
- MaskedValueIsZero(V1, *C2, Q.DL, 0, Q.AC, Q.CxtI, Q.DT))
+ if (MaskedValueIsZero(N, *C2, Q.DL, 0, Q.AC, Q.CxtI, Q.DT))
return A;
}
// Or commutes, try both ways.
if (C1->isMask() &&
- match(B, m_Add(m_Value(V1), m_Value(V2)))) {
+ match(B, m_Add(m_Specific(A), m_Value(N)))) {
// Add commutes, try both ways.
- if (V1 == A &&
- MaskedValueIsZero(V2, *C1, Q.DL, 0, Q.AC, Q.CxtI, Q.DT))
- return B;
- if (V2 == A &&
- MaskedValueIsZero(V1, *C1, Q.DL, 0, Q.AC, Q.CxtI, Q.DT))
+ if (MaskedValueIsZero(N, *C1, Q.DL, 0, Q.AC, Q.CxtI, Q.DT))
return B;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33585.100434.patch
Type: text/x-patch
Size: 1430 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170526/68f1963d/attachment.bin>
More information about the llvm-commits
mailing list