Commit 937c812d authored by Julia Lawall's avatar Julia Lawall Committed by Masahiro Yamada

coccinelle: orplus: reorganize to improve performance

Adding two #define constants is less common than performing & and |
operations on them, so put the addition first to reduce the set of cases
that have to be considered in detail.  At the same time, add & and |
patterns for both arguments of +, to account for commutativity and obtain
more results.

Running time is divided by 3 when applying this to the whole kernel on my
laptop with an Intel i5-6200U CPU.
Signed-off-by: default avatarJulia Lawall <julia.lawall@lip6.fr>
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
parent 6851ba1a
...@@ -14,7 +14,19 @@ virtual report ...@@ -14,7 +14,19 @@ virtual report
virtual context virtual context
@r@ @r@
constant c; constant c,c1;
identifier i,i1;
position p;
@@
(
c1 + c - 1
|
c1@i1 +@p c@i
)
@s@
constant r.c, r.c1;
identifier i; identifier i;
expression e; expression e;
@@ @@
...@@ -27,28 +39,31 @@ e & c@i ...@@ -27,28 +39,31 @@ e & c@i
e |= c@i e |= c@i
| |
e &= c@i e &= c@i
|
e | c1@i
|
e & c1@i
|
e |= c1@i
|
e &= c1@i
) )
@s@ @depends on s@
constant r.c,c1; position r.p;
identifier i1; constant c1,c2;
position p;
@@ @@
( * c1 +@p c2
c1 + c - 1
|
*c1@i1 +@p c
)
@script:python depends on org@ @script:python depends on s && org@
p << s.p; p << r.p;
@@ @@
cocci.print_main("sum of probable bitmasks, consider |",p) cocci.print_main("sum of probable bitmasks, consider |",p)
@script:python depends on report@ @script:python depends on s && report@
p << s.p; p << r.p;
@@ @@
msg = "WARNING: sum of probable bitmasks, consider |" msg = "WARNING: sum of probable bitmasks, consider |"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment