aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2017-11-13 00:53:35 -0500
committerMasahiro Yamada <yamada.masahiro@socionext.com>2017-11-15 18:56:42 -0500
commit937c812dfc0a25343d56b07734438610a1fb7b46 (patch)
treead1f1cd178171d99fbd98e7bace9340b8f9bad13
parent6851ba1a1b22ba2e0800002d531bf04ced22ec18 (diff)
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: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
-rw-r--r--scripts/coccinelle/misc/orplus.cocci43
1 files changed, 29 insertions, 14 deletions
diff --git a/scripts/coccinelle/misc/orplus.cocci b/scripts/coccinelle/misc/orplus.cocci
index 81fabf379390..08de5be73693 100644
--- a/scripts/coccinelle/misc/orplus.cocci
+++ b/scripts/coccinelle/misc/orplus.cocci
@@ -14,7 +14,19 @@ virtual report
14virtual context 14virtual context
15 15
16@r@ 16@r@
17constant c; 17constant c,c1;
18identifier i,i1;
19position p;
20@@
21
22(
23 c1 + c - 1
24|
25 c1@i1 +@p c@i
26)
27
28@s@
29constant r.c, r.c1;
18identifier i; 30identifier i;
19expression e; 31expression e;
20@@ 32@@
@@ -27,28 +39,31 @@ e & c@i
27e |= c@i 39e |= c@i
28| 40|
29e &= c@i 41e &= c@i
42|
43e | c1@i
44|
45e & c1@i
46|
47e |= c1@i
48|
49e &= c1@i
30) 50)
31 51
32@s@ 52@depends on s@
33constant r.c,c1; 53position r.p;
34identifier i1; 54constant c1,c2;
35position p;
36@@ 55@@
37 56
38( 57* c1 +@p c2
39 c1 + c - 1
40|
41*c1@i1 +@p c
42)
43 58
44@script:python depends on org@ 59@script:python depends on s && org@
45p << s.p; 60p << r.p;
46@@ 61@@
47 62
48cocci.print_main("sum of probable bitmasks, consider |",p) 63cocci.print_main("sum of probable bitmasks, consider |",p)
49 64
50@script:python depends on report@ 65@script:python depends on s && report@
51p << s.p; 66p << r.p;
52@@ 67@@
53 68
54msg = "WARNING: sum of probable bitmasks, consider |" 69msg = "WARNING: sum of probable bitmasks, consider |"