diff options
author | Michael Forney <mforney@mforney.org> | 2021-06-29 22:36:01 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2021-06-30 11:50:56 -0700 |
commit | 6ec058cb006357ec0da4c689fa0da5c3375d40f4 (patch) | |
tree | 532d01acf0c382daa6ee495ba7ea1ef4f4dee38a | |
parent | c16f07acf655b9f4fb006d8256b4027fb5a13aa8 (diff) | |
download | cproc-6ec058cb006357ec0da4c689fa0da5c3375d40f4.tar.xz |
qbe: Remove before unnecessary adds during copy
-rw-r--r-- | qbe.c | 6 | ||||
-rw-r--r-- | test/builtin-va-copy.qbe | 2 | ||||
-rw-r--r-- | test/struct-copy.qbe | 2 |
3 files changed, 5 insertions, 5 deletions
@@ -308,9 +308,13 @@ funcstore(struct func *f, struct type *t, enum typequal tq, struct lvalue lval, src = v; dst = lval.addr; align = mkintconst(&iptr, t->align); - for (offset = 0; offset < t->size; offset += t->align) { + offset = 0; + for (;;) { tmp = funcinst(f, loadop, &iptr, src, NULL); funcinst(f, storeop, NULL, tmp, dst); + offset += t->align; + if (offset >= t->size) + break; src = funcinst(f, IADD, &iptr, src, align); dst = funcinst(f, IADD, &iptr, dst, align); } diff --git a/test/builtin-va-copy.qbe b/test/builtin-va-copy.qbe index 913fbd3..6c8d288 100644 --- a/test/builtin-va-copy.qbe +++ b/test/builtin-va-copy.qbe @@ -18,7 +18,5 @@ function $f() { %.9 =l add %.6, 8 %.10 =l loadl %.8 storel %.10, %.9 - %.11 =l add %.8, 8 - %.12 =l add %.9, 8 ret } diff --git a/test/struct-copy.qbe b/test/struct-copy.qbe index eb2c955..684952f 100644 --- a/test/struct-copy.qbe +++ b/test/struct-copy.qbe @@ -13,8 +13,6 @@ function $f() { %.7 =l add %.4, 4 %.8 =l loaduw %.6 storew %.8, %.7 - %.9 =l add %.6, 4 - %.10 =l add %.7, 4 ret } export data $x = align 4 { z 12 } |