ソースを参照

only restrict (lt|gt)e? optimizations to ints, don't restrict (not?)eq (see #4889)

Dan Korostelev 9 年 前
コミット
2f11f2374a
1 ファイル変更16 行追加14 行削除
  1. 16 14
      optimizer.ml

+ 16 - 14
optimizer.ml

@@ -1219,20 +1219,22 @@ let optimize_unop e op flag esub =
 	in
 	match op, esub.eexpr with
 		| 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
 		| Neg, TConst (TInt i) -> { e with eexpr = TConst (TInt (Int32.neg i)) }
 		| NegBits, TConst (TInt i) -> { e with eexpr = TConst (TInt (Int32.lognot i)) }