aboutsummaryrefslogtreecommitdiffstats
path: root/backend/CSE2.v
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-03-03 06:13:05 +0100
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-03-03 06:13:05 +0100
commita398b5750ceeeab90a44b2e1d34fe6d5ff8b1f08 (patch)
tree5f22972f5e9c74999dab5405757aae9f9631a258 /backend/CSE2.v
parent93bf7e0925b1c11e1874ae5f651970db2bd9823d (diff)
downloadcompcert-kvx-a398b5750ceeeab90a44b2e1d34fe6d5ff8b1f08.tar.gz
compcert-kvx-a398b5750ceeeab90a44b2e1d34fe6d5ff8b1f08.zip
with indexed/indexed alias analysis for x86
Diffstat (limited to 'backend/CSE2.v')
-rw-r--r--backend/CSE2.v26
1 files changed, 24 insertions, 2 deletions
diff --git a/backend/CSE2.v b/backend/CSE2.v
index a03e02a4..f5ff8748 100644
--- a/backend/CSE2.v
+++ b/backend/CSE2.v
@@ -281,16 +281,38 @@ Definition kill_sym_val_mem (sv: sym_val) :=
| SLoad _ _ _ => true
end.
+Definition may_overlap chunk addr args chunk' addr' args' :=
+ match addr, addr', args, args' with
+ | (Aindexed ofs), (Aindexed ofs'),
+ (base :: nil), (base' :: nil) =>
+ if peq base base'
+ then negb (can_swap_accesses_ofs ofs' chunk' ofs chunk)
+ else true
+ | _, _, _, _ => true
+ end.
+
+Definition kill_sym_val_store chunk addr args (sv: sym_val) :=
+ match sv with
+ | SMove _ => false
+ | SOp op _ => op_depends_on_memory op
+ | SLoad chunk' addr' args' => may_overlap chunk addr args chunk' addr' args'
+ end.
+
Definition kill_mem (rel : RELATION.t) :=
PTree.filter1 (fun x => negb (kill_sym_val_mem x)) rel.
-
Definition forward_move (rel : RELATION.t) (x : reg) : reg :=
match rel ! x with
| Some (SMove org) => org
| _ => x
end.
+Definition kill_store1 chunk addr args rel :=
+ PTree.filter1 (fun x => negb (kill_sym_val_store chunk addr args x)) rel.
+
+Definition kill_store chunk addr args rel :=
+ kill_store1 chunk addr (List.map (forward_move rel) args) rel.
+
Definition move (src dst : reg) (rel : RELATION.t) :=
PTree.set dst (SMove (forward_move rel src)) (kill_reg dst rel).
@@ -403,7 +425,7 @@ Definition apply_instr instr (rel : RELATION.t) : RB.t :=
| Inop _
| Icond _ _ _ _
| Ijumptable _ _ => Some rel
- | Istore _ _ _ _ _ => Some (kill_mem rel)
+ | Istore chunk addr args _ _ => Some (kill_store chunk addr args rel)
| Iop op args dst _ => Some (gen_oper op dst args rel)
| Iload chunk addr args dst _ => Some (load chunk addr dst args rel)
| Icall _ _ _ dst _ => Some (kill_reg dst (kill_mem rel))