aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jason Gross <jgross@mit.edu>2017-06-24 23:28:30 -0400
committerGravatar Jason Gross <jgross@mit.edu>2017-06-24 23:28:30 -0400
commit0e33896644d27a19990593b8d4066de008e0a431 (patch)
tree6567b36fa8bd5799977000ce9b59ddd2ca5b1a78 /src
parente35385ed17d49ddc05928a2cbd74c190516acf66 (diff)
Propogate neg through constant multiplication
Diffstat (limited to 'src')
-rw-r--r--src/Compilers/Z/ArithmeticSimplifier.v4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/Compilers/Z/ArithmeticSimplifier.v b/src/Compilers/Z/ArithmeticSimplifier.v
index 6cafa3230..24072dc71 100644
--- a/src/Compilers/Z/ArithmeticSimplifier.v
+++ b/src/Compilers/Z/ArithmeticSimplifier.v
@@ -148,7 +148,9 @@ Section language.
then Op (Opp _ _) e
else if (v =? -1)%Z
then e
- else Op opc args
+ else if (v >? 0)%Z
+ then Op (Opp _ _) (Op opc (Pair (Op (OpConst v) TT) e))
+ else Op opc args
| Some (gen_expr e1, neg_expr e2)
| Some (neg_expr e1, gen_expr e2)
=> Op (Opp _ _) (Op (Mul _ _ TZ) (Pair e1 e2))