(* WARNING: this is generated by running 'nowhere mltree-simplify.in'. * Do not edit this file directly. * Version 1.2.2 *) (*#line 15.1 "mltree-simplify.in"*) functor MLTreeSimplifier( (*#line 16.4 "mltree-simplify.in"*) structure T : MLTREE (*#line 17.4 "mltree-simplify.in"*) structure Size : MLTREE_SIZE (* where T=T *) where type T.Basis.cond = T.Basis.cond and type T.Basis.div_rounding_mode = T.Basis.div_rounding_mode and type T.Basis.ext = T.Basis.ext and type T.Basis.fcond = T.Basis.fcond and type T.Basis.rounding_mode = T.Basis.rounding_mode and type T.Constant.const = T.Constant.const and type ('s,'r,'f,'c) T.Extension.ccx = ('s,'r,'f,'c) T.Extension.ccx and type ('s,'r,'f,'c) T.Extension.fx = ('s,'r,'f,'c) T.Extension.fx and type ('s,'r,'f,'c) T.Extension.rx = ('s,'r,'f,'c) T.Extension.rx and type ('s,'r,'f,'c) T.Extension.sx = ('s,'r,'f,'c) T.Extension.sx and type T.I.div_rounding_mode = T.I.div_rounding_mode and type T.Region.region = T.Region.region and type T.ccexp = T.ccexp and type T.fexp = T.fexp (* and type T.labexp = T.labexp *) and type T.mlrisc = T.mlrisc and type T.oper = T.oper and type T.rep = T.rep and type T.rexp = T.rexp and type T.stm = T.stm (*#line 20.4 "mltree-simplify.in"*) val sext : T.rewriter -> T.sext -> T.sext (*#line 21.4 "mltree-simplify.in"*) val rext : T.rewriter -> T.rext -> T.rext (*#line 22.4 "mltree-simplify.in"*) val fext : T.rewriter -> T.fext -> T.fext (*#line 23.4 "mltree-simplify.in"*) val ccext : T.rewriter -> T.ccext -> T.ccext ): MLTREE_SIMPLIFIER = struct (*#line 27.4 "mltree-simplify.in"*) structure T = T (*#line 28.4 "mltree-simplify.in"*) structure I = T.I (*#line 29.4 "mltree-simplify.in"*) structure R = MLTreeRewrite ( (*#line 30.7 "mltree-simplify.in"*) structure T = T (*#line 31.7 "mltree-simplify.in"*) val sext = sext and rext = rext and fext = fext and ccext = ccext ) (*#line 34.4 "mltree-simplify.in"*) type simplifier = T.rewriter (*#line 36.4 "mltree-simplify.in"*) val lit_11 = (IntInf.fromInt 0) and lit_16 = (IntInf.fromInt 1) (*#line 37.4 "mltree-simplify.in"*) val zero = (IntInf.fromInt 0) (*#line 38.4 "mltree-simplify.in"*) val zeroT = T.LI zero (*#line 40.4 "mltree-simplify.in"*) fun simplify {addressWidth, signedAddress} = let (*#line 43.4 "mltree-simplify.in"*) fun dm (T.DIV_TO_ZERO) = I.DIV_TO_ZERO | dm (T.DIV_TO_NEGINF) = I.DIV_TO_NEGINF (*#line 46.4 "mltree-simplify.in"*) fun sim ==> exp = let val v_3 = exp fun state_165 e = e fun state_149 () = zeroT fun state_158 () = zeroT fun state_180 v_3 = let val exp = v_3 in exp end fun state_118 (v_1, v_4) = let val b = v_4 and ty = v_1 in b end fun state_15 (v_1, v_0) = let val a = v_0 and ty = v_1 in a end fun state_148 v_1 = let val ty = v_1 in zeroT end fun state_140 v_1 = let val ty = v_1 in zeroT end fun state_157 v_1 = let val ty = v_1 in zeroT end fun state_109 v_4 = let val b = v_4 in b end fun state_45 (v_1, v_4) = let val ty = v_1 and x = v_4 in x end fun state_43 v_1 = let val ty = v_1 in zeroT end fun state_47 (v_1, v_0) = let val ty = v_1 and x = v_0 in x end fun state_85 (v_1, v_4) = let val ty = v_1 and x = v_4 in x end fun state_83 v_1 = let val ty = v_1 in zeroT end fun state_87 (v_1, v_0) = let val ty = v_1 and x = v_0 in x end fun state_23 (v_1, v_4) = let val ty = v_1 and x = v_4 in x end fun state_21 v_1 = let val ty = v_1 in zeroT end fun state_25 (v_1, v_0) = let val ty = v_1 and x = v_0 in x end fun state_127 (v_1, v_4) = let val b = v_4 and ty = v_1 in zeroT end fun state_100 v_0 = let val a = v_0 in a end fun state_69 (v_1, v_0) = let val ty = v_1 and x = v_0 in x end fun state_5 (v_1, v_0) = let val ty = v_1 and x = v_0 in x end fun state_1717 (v_3, v_1, v_10, v_4) = (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then (state_118 (v_1, v_4)) else (state_180 v_3)) fun state_1450 (v_3, v_1, v_0, v_2) = (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then (state_15 (v_1, v_0)) else (state_180 v_3)) fun state_1279 (v_3, v_1, v_10) = (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then (state_148 v_1) else (state_180 v_3)) fun state_1192 (v_3, v_1, v_10) = (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then (state_140 v_1) else (state_180 v_3)) fun state_1021 (v_3, v_1, v_10) = (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then (state_157 v_1) else (state_180 v_3)) fun state_916 (v_3, v_10, v_4) = (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then (state_109 v_4) else (state_180 v_3)) fun state_820 (v_3, v_1, v_0, v_2) = (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then (state_43 v_1) else (if ((IntInf.compare (v_2, lit_16)) = EQUAL) then (state_47 (v_1, v_0)) else (state_180 v_3))) fun state_731 (v_3, v_1, v_0, v_2) = (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then (state_83 v_1) else (if ((IntInf.compare (v_2, lit_16)) = EQUAL) then (state_87 (v_1, v_0)) else (state_180 v_3))) fun state_642 (v_3, v_1, v_0, v_2) = (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then (state_21 v_1) else (if ((IntInf.compare (v_2, lit_16)) = EQUAL) then (state_25 (v_1, v_0)) else (state_180 v_3))) fun state_555 (v_3, v_1, v_10, v_4) = (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then (state_127 (v_1, v_4)) else (state_180 v_3)) fun state_441 (v_3, v_0, v_10) = (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then (state_100 v_0) else (state_180 v_3)) fun state_354 (v_3, v_1, v_0, v_2) = (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then (state_69 (v_1, v_0)) else (state_180 v_3)) fun state_181 (v_3, v_1, v_0, v_2) = (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then (state_5 (v_1, v_0)) else (state_180 v_3)) fun state_1451 (v_3, v_1, v_0, v_4) = (case v_4 of T.LI v_2 => state_1450 (v_3, v_1, v_0, v_2) | _ => state_180 v_3 ) fun state_182 (v_3, v_1, v_0, v_4) = (case v_4 of T.LI v_2 => state_181 (v_3, v_1, v_0, v_2) | _ => state_180 v_3 ) in (case v_3 of T.ADD v_5 => let val (v_1, v_0, v_4) = v_5 in (case v_0 of T.ADD v_10 => let val (v_7, v_9, v_13) = v_10 in (case v_13 of T.LI v_12 => (case v_4 of T.LI v_2 => let val a = v_9 and ty = v_1 and ty' = v_7 and x = v_12 and y = v_2 in (if (ty = ty') then (T.ADD (ty, a, T.LI (I.ADD (ty, x, y)))) else (state_181 (v_3, v_1, v_0, v_2))) end | _ => state_180 v_3 ) | _ => state_182 (v_3, v_1, v_0, v_4) ) end | T.LABEXP v_10 => (case v_4 of T.LABEXP v_2 => let val ty = v_1 and x = v_10 and y = v_2 in T.LABEXP (T.ADD (ty, x, y)) end | T.LI v_2 => state_181 (v_3, v_1, v_0, v_2) | _ => state_180 v_3 ) | T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then let val ty = v_1 and x = v_4 in x end else (case v_4 of T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then (state_5 (v_1, v_0)) else let val ty = v_1 and x = v_10 and y = v_2 in T.LI (I.ADD (ty, x, y)) end) | _ => state_180 v_3 )) | _ => state_182 (v_3, v_1, v_0, v_4) ) end | T.ADDT v_5 => let val (v_1, v_0, v_4) = v_5 in (case v_0 of T.LABEXP v_10 => (case v_4 of T.LABEXP v_2 => let val ty = v_1 and x = v_10 and y = v_2 in T.LABEXP (T.ADDT (ty, x, y)) end | T.LI v_2 => state_354 (v_3, v_1, v_0, v_2) | _ => state_180 v_3 ) | T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then let val ty = v_1 and x = v_4 in x end else (case v_4 of T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then (state_69 (v_1, v_0)) else let val ty = v_1 and x = v_10 and y = v_2 in ((T.LI (I.ADDT (ty, x, y))) handle Overflow => exp ) end) | _ => state_180 v_3 )) | _ => (case v_4 of T.LI v_2 => state_354 (v_3, v_1, v_0, v_2) | _ => state_180 v_3 ) ) end | T.ANDB v_5 => let val (v_1, v_0, v_4) = v_5 in (case v_4 of T.LABEXP v_2 => (case v_0 of T.LABEXP v_10 => let val ty = v_1 and x = v_10 and y = v_2 in T.LABEXP (T.ANDB (ty, x, y)) end | T.LI v_10 => state_441 (v_3, v_0, v_10) | _ => state_180 v_3 ) | T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then let val b = v_4 in b end else (case v_0 of T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then (state_100 v_0) else let val ty = v_1 and x = v_10 and y = v_2 in T.LI (I.ANDB (ty, x, y)) end) | _ => state_180 v_3 )) | T.NOTB v_2 => (case v_0 of T.LI v_10 => state_441 (v_3, v_0, v_10) | T.NOTB v_10 => let val (v_7, v_9) = v_10 in let val (v_6, v_8) = v_2 in let val a = v_9 and b = v_8 and ty = v_1 and ty' = v_7 and ty'' = v_6 in (if ((ty = ty') andalso (ty' = ty'')) then (T.NOTB (ty, T.ORB (ty, a, b))) else (state_180 v_3)) end end end | _ => state_180 v_3 ) | _ => (case v_0 of T.LI v_10 => state_441 (v_3, v_0, v_10) | _ => state_180 v_3 ) ) end | T.COND v_5 => let val (v_1, v_0, v_4, v_18) = v_5 in (case v_0 of T.FALSE => let val a = v_4 and b = v_18 and ty = v_1 in b end | T.TRUE => let val a = v_4 and b = v_18 and ty = v_1 in a end | _ => state_180 v_3 ) end | T.DIVS v_5 => let val (v_1, v_0, v_4, v_18) = v_5 in (case v_18 of T.LABEXP v_17 => (case v_4 of T.LABEXP v_2 => let val m = v_1 and ty = v_0 and x = v_2 and y = v_17 in T.LABEXP (T.DIVS (m, ty, x, y)) end | _ => state_180 v_3 ) | T.LI v_17 => (if ((IntInf.compare (v_17, lit_16)) = EQUAL) then let val a = v_4 and m = v_1 and ty = v_0 in a end else (case v_4 of T.LI v_2 => let val m = v_1 and ty = v_0 and x = v_2 and y = v_17 in (if (y <> zero) then (T.LI (I.DIVS (dm m, ty, x, y))) else (state_180 v_3)) end | _ => state_180 v_3 )) | _ => state_180 v_3 ) end | T.DIVT v_5 => let val (v_1, v_0, v_4, v_18) = v_5 in (case v_18 of T.LABEXP v_17 => (case v_4 of T.LABEXP v_2 => let val m = v_1 and ty = v_0 and x = v_2 and y = v_17 in T.LABEXP (T.DIVT (m, ty, x, y)) end | _ => state_180 v_3 ) | T.LI v_17 => (if ((IntInf.compare (v_17, lit_16)) = EQUAL) then let val a = v_4 and m = v_1 and ty = v_0 in a end else (case v_4 of T.LI v_2 => let val m = v_1 and ty = v_0 and x = v_2 and y = v_17 in (if (y <> zero) then (T.LI (I.DIVT (dm m, ty, x, y))) else (state_180 v_3)) end | _ => state_180 v_3 )) | _ => state_180 v_3 ) end | T.DIVU v_5 => let val (v_1, v_0, v_4) = v_5 in (case v_4 of T.LABEXP v_2 => (case v_0 of T.LABEXP v_10 => let val ty = v_1 and x = v_10 and y = v_2 in T.LABEXP (T.DIVU (ty, x, y)) end | _ => state_180 v_3 ) | T.LI v_2 => (if ((IntInf.compare (v_2, lit_16)) = EQUAL) then let val a = v_0 and ty = v_1 in a end else (case v_0 of T.LI v_10 => let val ty = v_1 and x = v_10 and y = v_2 in (if (y <> zero) then (T.LI (I.DIVU (ty, x, y))) else (state_180 v_3)) end | _ => state_180 v_3 )) | _ => state_180 v_3 ) end | T.EQVB v_5 => let val (v_1, v_0, v_4) = v_5 in (case v_4 of T.LABEXP v_2 => (case v_0 of T.LABEXP v_10 => let val ty = v_1 and x = v_10 and y = v_2 in T.LABEXP (T.EQVB (ty, x, y)) end | T.LI v_10 => state_555 (v_3, v_1, v_10, v_4) | _ => state_180 v_3 ) | T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then let val a = v_0 and ty = v_1 in zeroT end else (case v_0 of T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then (state_127 (v_1, v_4)) else let val ty = v_1 and x = v_10 and y = v_2 in T.LI (I.EQVB (ty, x, y)) end) | _ => state_180 v_3 )) | _ => (case v_0 of T.LI v_10 => state_555 (v_3, v_1, v_10, v_4) | _ => state_180 v_3 ) ) end | T.MULS v_5 => let val (v_1, v_0, v_4) = v_5 in (case v_0 of T.LABEXP v_10 => (case v_4 of T.LABEXP v_2 => let val ty = v_1 and x = v_10 and y = v_2 in T.LABEXP (T.MULS (ty, x, y)) end | T.LI v_2 => state_642 (v_3, v_1, v_0, v_2) | _ => state_180 v_3 ) | T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then let val ty = v_1 in zeroT end else (if ((IntInf.compare (v_10, lit_16)) = EQUAL) then (case v_4 of T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then (state_21 v_1) else (if ((IntInf.compare (v_2, lit_16)) = EQUAL) then (state_23 (v_1, v_4)) else (state_23 (v_1, v_4)))) | _ => state_23 (v_1, v_4) ) else (case v_4 of T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then (state_21 v_1) else (if ((IntInf.compare (v_2, lit_16)) = EQUAL) then (state_25 (v_1, v_0)) else let val ty = v_1 and x = v_10 and y = v_2 in T.LI (I.MULS (ty, x, y)) end)) | _ => state_180 v_3 ))) | _ => (case v_4 of T.LI v_2 => state_642 (v_3, v_1, v_0, v_2) | _ => state_180 v_3 ) ) end | T.MULT v_5 => let val (v_1, v_0, v_4) = v_5 in (case v_0 of T.LABEXP v_10 => (case v_4 of T.LABEXP v_2 => let val ty = v_1 and x = v_10 and y = v_2 in T.LABEXP (T.MULT (ty, x, y)) end | T.LI v_2 => state_731 (v_3, v_1, v_0, v_2) | _ => state_180 v_3 ) | T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then let val ty = v_1 in zeroT end else (if ((IntInf.compare (v_10, lit_16)) = EQUAL) then (case v_4 of T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then (state_83 v_1) else (if ((IntInf.compare (v_2, lit_16)) = EQUAL) then (state_85 (v_1, v_4)) else (state_85 (v_1, v_4)))) | _ => state_85 (v_1, v_4) ) else (case v_4 of T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then (state_83 v_1) else (if ((IntInf.compare (v_2, lit_16)) = EQUAL) then (state_87 (v_1, v_0)) else let val ty = v_1 and x = v_10 and y = v_2 in ((T.LI (I.MULT (ty, x, y))) handle Overflow => exp ) end)) | _ => state_180 v_3 ))) | _ => (case v_4 of T.LI v_2 => state_731 (v_3, v_1, v_0, v_2) | _ => state_180 v_3 ) ) end | T.MULU v_5 => let val (v_1, v_0, v_4) = v_5 in (case v_0 of T.LABEXP v_10 => (case v_4 of T.LABEXP v_2 => let val ty = v_1 and x = v_10 and y = v_2 in T.LABEXP (T.MULU (ty, x, y)) end | T.LI v_2 => state_820 (v_3, v_1, v_0, v_2) | _ => state_180 v_3 ) | T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then let val ty = v_1 in zeroT end else (if ((IntInf.compare (v_10, lit_16)) = EQUAL) then (case v_4 of T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then (state_43 v_1) else (if ((IntInf.compare (v_2, lit_16)) = EQUAL) then (state_45 (v_1, v_4)) else (state_45 (v_1, v_4)))) | _ => state_45 (v_1, v_4) ) else (case v_4 of T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then (state_43 v_1) else (if ((IntInf.compare (v_2, lit_16)) = EQUAL) then (state_47 (v_1, v_0)) else let val ty = v_1 and x = v_10 and y = v_2 in T.LI (I.MULU (ty, x, y)) end)) | _ => state_180 v_3 ))) | _ => (case v_4 of T.LI v_2 => state_820 (v_3, v_1, v_0, v_2) | _ => state_180 v_3 ) ) end | T.NEGT v_5 => let val (v_1, v_0) = v_5 in (case v_0 of T.LABEXP v_10 => let val ty = v_1 and x = v_10 in T.LABEXP (T.NEGT (ty, x)) end | T.LI v_10 => let val ty = v_1 and x = v_10 in ((T.LI (I.NEGT (ty, x))) handle Overflow => exp ) end | _ => state_180 v_3 ) end | T.NOTB v_5 => let val (v_1, v_0) = v_5 in (case v_0 of T.LABEXP v_10 => let val ty = v_1 and x = v_10 in T.LABEXP (T.NOTB (ty, x)) end | T.LI v_10 => let val n = v_10 and ty = v_1 in T.LI (I.NOTB (ty, n)) end | T.NOTB v_10 => let val (v_7, v_9) = v_10 in let val a = v_9 and ty = v_1 and ty' = v_7 in (if (ty = ty') then a else (state_180 v_3)) end end | _ => state_180 v_3 ) end | T.ORB v_5 => let val (v_1, v_0, v_4) = v_5 in (case v_4 of T.LABEXP v_2 => (case v_0 of T.LABEXP v_10 => let val ty = v_1 and x = v_10 and y = v_2 in T.LABEXP (T.ORB (ty, x, y)) end | T.LI v_10 => state_916 (v_3, v_10, v_4) | _ => state_180 v_3 ) | T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then let val a = v_0 in a end else (case v_0 of T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then (state_109 v_4) else let val ty = v_1 and x = v_10 and y = v_2 in T.LI (I.ORB (ty, x, y)) end) | _ => state_180 v_3 )) | T.NOTB v_2 => (case v_0 of T.LI v_10 => state_916 (v_3, v_10, v_4) | T.NOTB v_10 => let val (v_7, v_9) = v_10 in let val (v_6, v_8) = v_2 in let val a = v_9 and b = v_8 and ty = v_1 and ty' = v_7 and ty'' = v_6 in (if ((ty = ty') andalso (ty' = ty'')) then (T.NOTB (ty, T.ANDB (ty, a, b))) else (state_180 v_3)) end end end | _ => state_180 v_3 ) | _ => (case v_0 of T.LI v_10 => state_916 (v_3, v_10, v_4) | _ => state_180 v_3 ) ) end | T.REMS v_5 => let val (v_1, v_0, v_4, v_18) = v_5 in (case v_18 of T.LABEXP v_17 => (case v_4 of T.LABEXP v_2 => let val m = v_1 and ty = v_0 and x = v_2 and y = v_17 in T.LABEXP (T.REMS (m, ty, x, y)) end | _ => state_180 v_3 ) | T.LI v_17 => (if ((IntInf.compare (v_17, lit_16)) = EQUAL) then let val a = v_4 and m = v_1 and ty = v_0 in zeroT end else (case v_4 of T.LI v_2 => let val m = v_1 and ty = v_0 and x = v_2 and y = v_17 in (if (y <> zero) then (T.LI (I.REMS (dm m, ty, x, y))) else (state_180 v_3)) end | _ => state_180 v_3 )) | _ => state_180 v_3 ) end | T.REMU v_5 => let val (v_1, v_0, v_4) = v_5 in (case v_4 of T.LABEXP v_2 => (case v_0 of T.LABEXP v_10 => let val ty = v_1 and x = v_10 and y = v_2 in T.LABEXP (T.REMU (ty, x, y)) end | _ => state_180 v_3 ) | T.LI v_2 => (if ((IntInf.compare (v_2, lit_16)) = EQUAL) then let val a = v_0 and ty = v_1 in zeroT end else (case v_0 of T.LI v_10 => let val ty = v_1 and x = v_10 and y = v_2 in (if (y <> zero) then (T.LI (I.REMU (ty, x, y))) else (state_180 v_3)) end | _ => state_180 v_3 )) | _ => state_180 v_3 ) end | T.SLL v_5 => let val (v_1, v_0, v_4) = v_5 in (case v_4 of T.LABEXP v_2 => (case v_0 of T.LABEXP v_10 => let val ty = v_1 and x = v_10 and y = v_2 in T.LABEXP (T.SLL (ty, x, y)) end | T.LI v_10 => state_1021 (v_3, v_1, v_10) | _ => state_180 v_3 ) | T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then let val a = v_0 and ty = v_1 in a end else (case v_0 of T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then (state_157 v_1) else let val n = v_2 and ty = v_1 in (if (IntInf.<= (IntInf.fromInt ty, n)) then (state_158 ()) else let val ty = v_1 and x = v_10 and y = v_2 in T.LI (I.SLL (ty, x, y)) end) end) | _ => let val n = v_2 and ty = v_1 in (if (IntInf.<= (IntInf.fromInt ty, n)) then (state_158 ()) else (state_180 v_3)) end )) | _ => (case v_0 of T.LI v_10 => state_1021 (v_3, v_1, v_10) | _ => state_180 v_3 ) ) end | T.SRA v_5 => let val (v_1, v_0, v_4) = v_5 in (case v_4 of T.LABEXP v_2 => (case v_0 of T.LABEXP v_10 => let val ty = v_1 and x = v_10 and y = v_2 in T.LABEXP (T.SRA (ty, x, y)) end | T.LI v_10 => state_1192 (v_3, v_1, v_10) | _ => state_180 v_3 ) | T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then let val a = v_0 and ty = v_1 in a end else (case v_0 of T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then (state_140 v_1) else let val ty = v_1 and x = v_10 and y = v_2 in T.LI (I.SRA (ty, x, y)) end) | _ => state_180 v_3 )) | _ => (case v_0 of T.LI v_10 => state_1192 (v_3, v_1, v_10) | _ => state_180 v_3 ) ) end | T.SRL v_5 => let val (v_1, v_0, v_4) = v_5 in (case v_4 of T.LABEXP v_2 => (case v_0 of T.LABEXP v_10 => let val ty = v_1 and x = v_10 and y = v_2 in T.LABEXP (T.SRL (ty, x, y)) end | T.LI v_10 => state_1279 (v_3, v_1, v_10) | _ => state_180 v_3 ) | T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then let val a = v_0 and ty = v_1 in a end else (case v_0 of T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then (state_148 v_1) else let val n = v_2 and ty = v_1 in (if (IntInf.<= (IntInf.fromInt ty, n)) then (state_149 ()) else let val ty = v_1 and x = v_10 and y = v_2 in T.LI (I.SRL (ty, x, y)) end) end) | _ => let val n = v_2 and ty = v_1 in (if (IntInf.<= (IntInf.fromInt ty, n)) then (state_149 ()) else (state_180 v_3)) end )) | _ => (case v_0 of T.LI v_10 => state_1279 (v_3, v_1, v_10) | _ => state_180 v_3 ) ) end | T.SUB v_5 => let val (v_1, v_0, v_4) = v_5 in (case v_0 of T.LABEXP v_10 => (case v_4 of T.LABEXP v_2 => let val ty = v_1 and x = v_10 and y = v_2 in T.LABEXP (T.SUB (ty, x, y)) end | T.LI v_2 => state_1450 (v_3, v_1, v_0, v_2) | _ => state_180 v_3 ) | T.LI v_10 => (case v_4 of T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then (state_15 (v_1, v_0)) else let val ty = v_1 and x = v_10 and y = v_2 in T.LI (I.SUB (ty, x, y)) end) | T.SUB v_2 => let val (v_6, v_8, v_14) = v_2 in (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then (case v_8 of T.LI v_15 => (if ((IntInf.compare (v_15, lit_11)) = EQUAL) then let val a = v_14 and ty = v_1 and ty' = v_6 in (if (ty = ty') then a else (state_180 v_3)) end else (state_180 v_3)) | _ => state_180 v_3 ) else (state_180 v_3)) end | _ => state_180 v_3 ) | T.SUB v_10 => let val (v_7, v_9, v_13) = v_10 in (case v_13 of T.LI v_12 => (case v_4 of T.LI v_2 => let val a = v_9 and ty = v_1 and ty' = v_7 and x = v_12 and y = v_2 in (if (ty = ty') then (T.SUB (ty, a, T.LI (I.ADD (ty, x, y)))) else (state_1450 (v_3, v_1, v_0, v_2))) end | _ => state_180 v_3 ) | _ => state_1451 (v_3, v_1, v_0, v_4) ) end | _ => state_1451 (v_3, v_1, v_0, v_4) ) end | T.SUBT v_5 => let val (v_1, v_0, v_4) = v_5 in (case v_4 of T.LABEXP v_2 => (case v_0 of T.LABEXP v_10 => let val ty = v_1 and x = v_10 and y = v_2 in T.LABEXP (T.SUBT (ty, x, y)) end | _ => state_180 v_3 ) | T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then let val a = v_0 and ty = v_1 in a end else (case v_0 of T.LI v_10 => let val ty = v_1 and x = v_10 and y = v_2 in ((T.LI (I.SUBT (ty, x, y))) handle Overflow => exp ) end | _ => state_180 v_3 )) | _ => state_180 v_3 ) end | T.SX v_5 => let val (v_1, v_0, v_4) = v_5 in (case v_4 of T.LABEXP v_2 => let val e = v_4 and ty = v_1 and ty' = v_0 in (if (ty = ty') then (state_165 e) else let val ty = v_1 and ty' = v_0 and x = v_2 in T.LABEXP (T.SX (ty, ty', x)) end) end | T.LI v_2 => let val e = v_4 and ty = v_1 and ty' = v_0 in (if (ty = ty') then (state_165 e) else let val n = v_2 and ty = v_1 and ty' = v_0 in T.LI (I.SX (ty, ty', n)) end) end | T.LOAD v_2 => let val ty = v_1 and ty' = v_0 in exp end | _ => let val e = v_4 and ty = v_1 and ty' = v_0 in (if (ty = ty') then (state_165 e) else (state_180 v_3)) end ) end | T.XORB v_5 => let val (v_1, v_0, v_4) = v_5 in (case v_4 of T.LABEXP v_2 => (case v_0 of T.LABEXP v_10 => let val ty = v_1 and x = v_10 and y = v_2 in T.LABEXP (T.XORB (ty, x, y)) end | T.LI v_10 => state_1717 (v_3, v_1, v_10, v_4) | _ => state_180 v_3 ) | T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL) then let val a = v_0 and ty = v_1 in a end else (case v_0 of T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL) then (state_118 (v_1, v_4)) else let val ty = v_1 and x = v_10 and y = v_2 in T.LI (I.XORB (ty, x, y)) end) | _ => state_180 v_3 )) | T.NOTB v_2 => (case v_0 of T.LI v_10 => state_1717 (v_3, v_1, v_10, v_4) | T.NOTB v_10 => let val (v_7, v_9) = v_10 in let val (v_6, v_8) = v_2 in let val a = v_9 and b = v_8 and ty = v_1 and ty' = v_7 and ty'' = v_6 in (if ((ty = ty') andalso (ty' = ty'')) then (T.NOTB (ty, T.XORB (ty, a, b))) else (state_180 v_3)) end end end | _ => state_180 v_3 ) | _ => (case v_0 of T.LI v_10 => state_1717 (v_3, v_1, v_10, v_4) | _ => state_180 v_3 ) ) end | T.ZX v_5 => let val (v_1, v_0, v_4) = v_5 in let val e = v_4 and ty = v_1 and ty' = v_0 in (if (ty = ty') then e else (case v_4 of T.LABEXP v_2 => let val ty = v_1 and ty' = v_0 and x = v_2 in T.LABEXP (T.ZX (ty, ty', x)) end | T.LI v_2 => let val n = v_2 and ty = v_1 and ty' = v_0 in T.LI (I.ZX (ty, ty', n)) end | _ => state_180 v_3 )) end end | _ => state_180 v_3 ) end and simStm ==> (T.IF(T.TRUE, yes, no)) = yes | simStm ==> (T.IF(T.FALSE, yes, no)) = no | simStm ==> (T.SEQ[x]) = x | simStm ==> s = s and simF p_0 p_1 = let val v_29 = (p_0, p_1) fun state_8 (v_19, v_20) = let val ==> = v_19 and exp = v_20 in exp end in let val (v_19, v_20) = v_29 in (case v_20 of T.CVTF2F v_26 => let val (v_22, v_25, v_27) = v_26 in let val ==> = v_19 and e = v_27 and ty = v_22 and ty' = v_25 in (if (ty = ty') then e else (state_8 (v_19, v_20))) end end | T.FCOND v_26 => let val (v_22, v_25, v_27, v_28) = v_26 in (case v_25 of T.FALSE => let val ==> = v_19 and no = v_28 and ty = v_22 and yes = v_27 in no end | T.TRUE => let val ==> = v_19 and no = v_28 and ty = v_22 and yes = v_27 in yes end | _ => state_8 (v_19, v_20) ) end | T.FNEG v_26 => let val (v_22, v_25) = v_26 in (case v_25 of T.FNEG v_24 => let val (v_21, v_23) = v_24 in let val ==> = v_19 and e = v_23 and ty = v_22 and ty' = v_21 in (if (ty = ty') then e else (state_8 (v_19, v_20))) end end | _ => state_8 (v_19, v_20) ) end | _ => state_8 (v_19, v_20) ) end end and cc false = T.FALSE | cc true = T.TRUE and simCC ==> (T.CMP(ty, T.EQ, T.LI x, T.LI y)) = cc (I.EQ (ty, x, y)) | simCC ==> (T.CMP(ty, T.NE, T.LI x, T.LI y)) = cc (I.NE (ty, x, y)) | simCC ==> (T.CMP(ty, T.GT, T.LI x, T.LI y)) = cc (I.GT (ty, x, y)) | simCC ==> (T.CMP(ty, T.GE, T.LI x, T.LI y)) = cc (I.GE (ty, x, y)) | simCC ==> (T.CMP(ty, T.LT, T.LI x, T.LI y)) = cc (I.LT (ty, x, y)) | simCC ==> (T.CMP(ty, T.LE, T.LI x, T.LI y)) = cc (I.LE (ty, x, y)) | simCC ==> (T.CMP(ty, T.GTU, T.LI x, T.LI y)) = cc (I.GTU (ty, x, y)) | simCC ==> (T.CMP(ty, T.LTU, T.LI x, T.LI y)) = cc (I.LTU (ty, x, y)) | simCC ==> (T.CMP(ty, T.GEU, T.LI x, T.LI y)) = cc (I.GEU (ty, x, y)) | simCC ==> (T.CMP(ty, T.LEU, T.LI x, T.LI y)) = cc (I.LEU (ty, x, y)) | simCC ==> (T.AND(T.TRUE, x)) = x | simCC ==> (T.AND(x, T.TRUE)) = x | simCC ==> (T.AND(T.FALSE, x)) = T.FALSE | simCC ==> (T.AND(x, T.FALSE)) = T.FALSE | simCC ==> (T.OR(T.FALSE, x)) = x | simCC ==> (T.OR(x, T.FALSE)) = x | simCC ==> (T.OR(T.TRUE, x)) = T.TRUE | simCC ==> (T.OR(x, T.TRUE)) = T.TRUE | simCC ==> (T.XOR(T.TRUE, T.TRUE)) = T.FALSE | simCC ==> (T.XOR(T.FALSE, x)) = x | simCC ==> (T.XOR(x, T.FALSE)) = x | simCC ==> (T.XOR(T.TRUE, x)) = T.NOT x | simCC ==> (T.XOR(x, T.TRUE)) = T.NOT x | simCC ==> (T.EQV(T.FALSE, T.FALSE)) = T.TRUE | simCC ==> (T.EQV(T.TRUE, x)) = x | simCC ==> (T.EQV(x, T.TRUE)) = x | simCC ==> (T.EQV(T.FALSE, x)) = T.NOT x | simCC ==> (T.EQV(x, T.FALSE)) = T.NOT x | simCC ==> exp = exp in R.rewrite {rexp=sim, fexp=simF, ccexp=simCC, stm=simStm} end end