summaryrefslogtreecommitdiff
path: root/ia32/CombineOp.v
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2012-07-01 07:51:12 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2012-07-01 07:51:12 +0000
commit4abaa3fa312fcbe7ee9665853f52a5d37e703864 (patch)
tree8fb982f2dd6fca8990708aa30a04e537c38ab395 /ia32/CombineOp.v
parent9b8f0f6c4683dd00ee0e3422b84c9cc34510011e (diff)
Recombine x = cmp(...); if (x == 1) ...
and x = cmp(...); if (x != 1) ... git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1946 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'ia32/CombineOp.v')
-rw-r--r--ia32/CombineOp.v28
1 files changed, 24 insertions, 4 deletions
diff --git a/ia32/CombineOp.v b/ia32/CombineOp.v
index 1391f55..07d5a79 100644
--- a/ia32/CombineOp.v
+++ b/ia32/CombineOp.v
@@ -43,16 +43,36 @@ Function combine_compimm_eq_0 (x: valnum) : option(condition * list valnum) :=
| _ => None
end.
+Function combine_compimm_eq_1 (x: valnum) : option(condition * list valnum) :=
+ match get x with
+ | Some(Op (Ocmp c) ys) => Some (c, ys)
+ | _ => None
+ end.
+
+Function combine_compimm_ne_1 (x: valnum) : option(condition * list valnum) :=
+ match get x with
+ | Some(Op (Ocmp c) ys) => Some (negate_condition c, ys)
+ | _ => None
+ end.
+
Function combine_cond (cond: condition) (args: list valnum) : option(condition * list valnum) :=
match cond, args with
| Ccompimm Cne n, x::nil =>
- if Int.eq_dec n Int.zero then combine_compimm_ne_0 x else None
+ if Int.eq_dec n Int.zero then combine_compimm_ne_0 x
+ else if Int.eq_dec n Int.one then combine_compimm_ne_1 x
+ else None
| Ccompimm Ceq n, x::nil =>
- if Int.eq_dec n Int.zero then combine_compimm_eq_0 x else None
+ if Int.eq_dec n Int.zero then combine_compimm_eq_0 x
+ else if Int.eq_dec n Int.one then combine_compimm_eq_1 x
+ else None
| Ccompuimm Cne n, x::nil =>
- if Int.eq_dec n Int.zero then combine_compimm_ne_0 x else None
+ if Int.eq_dec n Int.zero then combine_compimm_ne_0 x
+ else if Int.eq_dec n Int.one then combine_compimm_ne_1 x
+ else None
| Ccompuimm Ceq n, x::nil =>
- if Int.eq_dec n Int.zero then combine_compimm_eq_0 x else None
+ if Int.eq_dec n Int.zero then combine_compimm_eq_0 x
+ else if Int.eq_dec n Int.one then combine_compimm_eq_1 x
+ else None
| _, _ => None
end.