|
@@ -1219,20 +1219,22 @@ let optimize_unop e op flag esub =
|
|
in
|
|
in
|
|
match op, esub.eexpr with
|
|
match op, esub.eexpr with
|
|
| Not, (TConst (TBool f) | TParenthesis({eexpr = TConst (TBool f)})) -> { e with eexpr = TConst (TBool (not f)) }
|
|
| Not, (TConst (TBool f) | TParenthesis({eexpr = TConst (TBool f)})) -> { e with eexpr = TConst (TBool (not f)) }
|
|
- | Not, (TBinop(op,e1,e2) | TParenthesis({eexpr = TBinop(op,e1,e2)})) when is_int e1.etype && is_int e2.etype ->
|
|
|
|
- begin try
|
|
|
|
- let op = match op with
|
|
|
|
- | OpGt -> OpLte
|
|
|
|
- | OpGte -> OpLt
|
|
|
|
- | OpLt -> OpGte
|
|
|
|
- | OpLte -> OpGt
|
|
|
|
- | OpEq -> OpNotEq
|
|
|
|
- | OpNotEq -> OpEq
|
|
|
|
- | _ -> raise Exit
|
|
|
|
- in
|
|
|
|
- {e with eexpr = TBinop(op,e1,e2)}
|
|
|
|
- with Exit ->
|
|
|
|
- e
|
|
|
|
|
|
+ | Not, (TBinop(op,e1,e2) | TParenthesis({eexpr = TBinop(op,e1,e2)})) ->
|
|
|
|
+ begin
|
|
|
|
+ let is_int = is_int e1.etype && is_int e2.etype in
|
|
|
|
+ try
|
|
|
|
+ let op = match is_int, op with
|
|
|
|
+ | true, OpGt -> OpLte
|
|
|
|
+ | true, OpGte -> OpLt
|
|
|
|
+ | true, OpLt -> OpGte
|
|
|
|
+ | true, OpLte -> OpGt
|
|
|
|
+ | _, OpEq -> OpNotEq
|
|
|
|
+ | _, OpNotEq -> OpEq
|
|
|
|
+ | _ -> raise Exit
|
|
|
|
+ in
|
|
|
|
+ {e with eexpr = TBinop(op,e1,e2)}
|
|
|
|
+ with Exit ->
|
|
|
|
+ e
|
|
end
|
|
end
|
|
| Neg, TConst (TInt i) -> { e with eexpr = TConst (TInt (Int32.neg i)) }
|
|
| Neg, TConst (TInt i) -> { e with eexpr = TConst (TInt (Int32.neg i)) }
|
|
| NegBits, TConst (TInt i) -> { e with eexpr = TConst (TInt (Int32.lognot i)) }
|
|
| NegBits, TConst (TInt i) -> { e with eexpr = TConst (TInt (Int32.lognot i)) }
|