|
@@ -737,8 +737,13 @@ and func ctx i =
|
|
|
begin match e1.eexpr,e2.eexpr with
|
|
|
| TLocal v1,TLocal v2 when v1 == v2 && not v1.v_capture && is_valid_assign_op op ->
|
|
|
begin match op,e3.eexpr with
|
|
|
- | OpAdd,TConst (TInt i32) when Int32.to_int i32 = 1 -> {e with eexpr = TUnop(Increment,Prefix,e1)}
|
|
|
- | OpSub,TConst (TInt i32) when Int32.to_int i32 = 1 -> {e with eexpr = TUnop(Decrement,Prefix,e1)}
|
|
|
+ | (OpAdd|OpSub) as op,TConst (TInt i32) when Int32.to_int i32 = 1 && ExtType.is_numeric (follow v1.v_type) ->
|
|
|
+ let op = match op with
|
|
|
+ | OpAdd -> Increment
|
|
|
+ | OpSub -> Decrement
|
|
|
+ | _ -> assert false
|
|
|
+ in
|
|
|
+ {e with eexpr = TUnop(op,Prefix,e1)}
|
|
|
| _ -> {e with eexpr = TBinop(OpAssignOp op,e1,e3)}
|
|
|
end
|
|
|
| _ ->
|