aboutsummaryrefslogtreecommitdiff
path: root/copy.c
diff options
context:
space:
mode:
authorRoland Paterson-Jones <[email protected]>2024-05-23 20:21:56 +0200
committerQuentin Carbonneaux <[email protected]>2024-06-09 22:33:38 +0200
commitcf9f95f5212db901bdf09e95dae4647f17bfb1e5 (patch)
treec464064b84ee8742499e4eef084b29a5c621a293 /copy.c
parent2c2051542b7671fd060560edf09516ecf56bf6fa (diff)
Optab-driven copy detection
Diffstat (limited to 'copy.c')
-rw-r--r--copy.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/copy.c b/copy.c
index 77a8f06..da3987f 100644
--- a/copy.c
+++ b/copy.c
@@ -20,27 +20,15 @@ iscopy(Ins *i, Ref r, Fn *fn)
[Wsw] = BIT(Wsw),
[Wuw] = BIT(Wuw),
};
+ Op *op;
bits b;
Tmp *t;
- switch (i->op) {
- case Ocopy:
+ if (i->op == Ocopy)
return 1;
- case Omul:
- case Odiv:
- case Oudiv:
- return iscon(i->arg[1], 1, fn);
- case Oadd:
- case Osub:
- case Oor:
- case Oxor:
- case Osar:
- case Oshl:
- case Oshr:
- return iscon(i->arg[1], 0, fn);
- default:
- break;
- }
+ op = &optab[i->op];
+ if (op->hasid && KBASE(i->cls) == 0)
+ return iscon(i->arg[1], op->idval, fn);
if (!isext(i->op) || rtype(r) != RTmp)
return 0;
if (i->op == Oextsw || i->op == Oextuw)