[LLVMdev] Efficient Pattern matching in Instruction Combine
suyog sarda
sardask01 at gmail.com
Thu Aug 7 09:46:56 PDT 2014
Hi,
All, Duncan, Rafael, David, Nick.
This is regarding pattern matching in InstructionCombine pass.
We use 'match' functions many times, but it doesn't do the pattern matching
effectively.
e.x. Lets take pattern :
(A ^ B) | ((B ^ C) ^ A) -> (A ^ B) | C
(B ^ A) | ((B ^ C) ^ A) -> (A ^ B) | C
Both the patterns above are same, since ^ is commutative in Op0.
But, 'match' pattern has to be written for both the patterns separately
since 'match' identifies pattern as it (like regular expression) and
doesn't
have the logic to determine that 'A^B' and 'B^A' are same.
I propose to improve 'match' functions where we can include the logic
to determine if an operation is commutative or not. If it is commutative,
then a single 'match' call should be able to detect both 'A^B' and 'B^A'.
So, basically we will modify the commutative 'match' functions.
There will be various permutations of it where one of the operand might be
a constant (I guess this is handled already as constant are re-associated to
RHS).
I will try to dig more on this.
Inputs/suggestions/comments on improving match functions are most awaited.
:)
Regards,
Suyog
--
With regards,
Suyog Sarda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140807/18c3e6ec/attachment.html>
More information about the llvm-dev
mailing list