Skip to content

Commit

Permalink
coccinelle: orplus: reorganize to improve performance
Browse files Browse the repository at this point in the history
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: Julia Lawall <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
  • Loading branch information
JuliaLawall authored and masahir0y committed Nov 15, 2017
1 parent 6851ba1 commit 937c812
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions scripts/coccinelle/misc/orplus.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@ virtual report
virtual context

@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;
expression e;
@@
Expand All @@ -27,28 +39,31 @@ e & c@i
e |= c@i
|
e &= c@i
|
e | c1@i
|
e & c1@i
|
e |= c1@i
|
e &= c1@i
)

@s@
constant r.c,c1;
identifier i1;
position p;
@depends on s@
position r.p;
constant c1,c2;
@@

(
c1 + c - 1
|
*c1@i1 +@p c
)
* c1 +@p c2

@script:python depends on org@
p << s.p;
@script:python depends on s && org@
p << r.p;
@@
cocci.print_main("sum of probable bitmasks, consider |",p)
@script:python depends on report@
p << s.p;
@script:python depends on s && report@
p << r.p;
@@
msg = "WARNING: sum of probable bitmasks, consider |"
Expand Down

0 comments on commit 937c812

Please sign in to comment.