File tree Expand file tree Collapse file tree 6 files changed +50
-8
lines changed Expand file tree Collapse file tree 6 files changed +50
-8
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,8 @@ let rec combine i allocstate =
63
63
i.arg i.res i.dbg next, allocstate)
64
64
end
65
65
| Iop (Icall_ind | Icall_imm _ | Iextcall _ |
66
- Itailcall_ind | Itailcall_imm _ | Iprobe _ ) ->
66
+ Itailcall_ind | Itailcall_imm _ | Iprobe _ |
67
+ Iintop Icheckbound | Iintop_imm (Icheckbound, _ )) ->
67
68
let newnext = combine_restart i.next in
68
69
(instr_cons_debug i.desc i.arg i.res i.dbg newnext,
69
70
allocstate)
Original file line number Diff line number Diff line change @@ -417,15 +417,16 @@ method is_simple_expr = function
417
417
| Cextcall { effects = No_effects ; coeffects = No_coeffects ; } ->
418
418
List. for_all self#is_simple_expr args
419
419
(* The following may have side effects *)
420
- | Capply _ | Cextcall _ | Calloc | Cstore _ | Craise _ | Cprobe _
421
- | Cprobe_is_enabled _ | Copaque -> false
420
+ | Capply _ | Cextcall _ | Calloc | Cstore _
421
+ | Craise _ | Ccheckbound
422
+ | Cprobe _ | Cprobe_is_enabled _ | Copaque -> false
422
423
| Cprefetch _ -> false (* avoid reordering *)
423
424
(* The remaining operations are simple if their args are *)
424
425
| Cload _ | Caddi | Csubi | Cmuli | Cmulhi _ | Cdivi | Cmodi | Cand | Cor
425
426
| Cxor | Clsl | Clsr | Casr | Ccmpi _ | Caddv | Cadda | Ccmpa _ | Cnegf
426
427
| Cclz _ | Cctz _ | Cpopcnt
427
428
| Cabsf | Caddf | Csubf | Cmulf | Cdivf | Cfloatofint | Cintoffloat
428
- | Ccmpf _ | Ccheckbound -> List. for_all self#is_simple_expr args
429
+ | Ccmpf _ -> List. for_all self#is_simple_expr args
429
430
end
430
431
| Cassign _ | Cifthenelse _ | Cswitch _ | Ccatch _ | Cexit _
431
432
| Ctrywith _ -> false
Original file line number Diff line number Diff line change @@ -63,7 +63,8 @@ let rec combine i allocstate =
63
63
i.arg i.res i.dbg next, allocstate)
64
64
end
65
65
| Iop (Icall_ind | Icall_imm _ | Iextcall _ |
66
- Itailcall_ind | Itailcall_imm _ | Iprobe _ ) ->
66
+ Itailcall_ind | Itailcall_imm _ | Iprobe _ |
67
+ Iintop Icheckbound | Iintop_imm (Icheckbound, _ )) ->
67
68
let newnext = combine_restart i.next in
68
69
(instr_cons_debug i.desc i.arg i.res i.dbg newnext,
69
70
allocstate)
Original file line number Diff line number Diff line change @@ -324,13 +324,14 @@ method is_simple_expr = function
324
324
| Cop (op , args , _ ) ->
325
325
begin match op with
326
326
(* The following may have side effects *)
327
- | Capply _ | Cextcall _ | Calloc | Cstore _ | Craise _ | Cprobe _
328
- | Cprobe_is_enabled _ -> false
327
+ | Capply _ | Cextcall _ | Calloc | Cstore _
328
+ | Craise _ | Ccheckbound
329
+ | Cprobe _ | Cprobe_is_enabled _ -> false
329
330
(* The remaining operations are simple if their args are *)
330
331
| Cload _ | Caddi | Csubi | Cmuli | Cmulhi | Cdivi | Cmodi | Cand | Cor
331
332
| Cxor | Clsl | Clsr | Casr | Ccmpi _ | Caddv | Cadda | Ccmpa _ | Cnegf
332
333
| Cabsf | Caddf | Csubf | Cmulf | Cdivf | Cfloatofint | Cintoffloat
333
- | Ccmpf _ | Ccheckbound -> List. for_all self#is_simple_expr args
334
+ | Ccmpf _ -> List. for_all self#is_simple_expr args
334
335
end
335
336
| Cassign _ | Cifthenelse _ | Cswitch _ | Ccatch _ | Cexit _
336
337
| Ctrywith _ -> false
Original file line number Diff line number Diff line change
1
+ (* TEST
2
+ * native *)
3
+
4
+ let glob = ref (1 , 2 )
5
+ let [@ inline never] combine1 x a =
6
+ begin try
7
+ glob := (2 , x);
8
+ glob := (3 , a.(4 ));
9
+ with
10
+ | Invalid_argument _ -> ()
11
+ end ;
12
+ ! glob
13
+
14
+ let [@ inline never] combine2 x a =
15
+ let loc = ref (1 , 2 ) in
16
+ begin try
17
+ loc := (2 , x);
18
+ loc := (3 , a.(4 ));
19
+ with
20
+ | Invalid_argument _ -> ()
21
+ end ;
22
+ ! loc
23
+
24
+ let [@ inline never] measure f =
25
+ let empty_array = [| |] in
26
+ let prebefore = Gc. minor_words () in
27
+ let before = Gc. minor_words () in
28
+ let r = f 42 empty_array in
29
+ assert (r = (2 , 42 ));
30
+ let after = Gc. minor_words () in
31
+ ((after -. before) -. (before -. prebefore))
32
+
33
+
34
+ let () =
35
+ Printf. printf " %10s: %.0f\n " " combine1" (measure combine1);
36
+ Printf. printf " %10s: %.0f\n " " combine2" (measure combine2)
Original file line number Diff line number Diff line change
1
+ combine1: 3
2
+ combine2: 3
You can’t perform that action at this time.
0 commit comments