aboutsummaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorRoland Paterson-Jones <[email protected]>2024-10-23 14:51:53 +0200
committerQuentin Carbonneaux <[email protected]>2026-01-13 18:11:30 +0100
commit5c1eb24e2c312021c7af4316e5adde53e270311a (patch)
treee661a5d0c58d58c0f7fb8fc84dba575a800cc646 /util.c
parent72010791374d3be2ab21ee5ca1146fce2382d88b (diff)
If-conversion RFC 4 - x86 only (for now), use cmovXX
Replacement of tiny conditional jump graphlets with conditional move instructions. Currently enabled only for x86. Arm64 support using cselXX will be essentially identical. Adds (internal) frontend sel0/sel1 ops with flag-specific backend xselXX following jnz implementation pattern. Testing: standard QBE, cproc, harec, hare, roland
Diffstat (limited to 'util.c')
-rw-r--r--util.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/util.c b/util.c
index 3b5c09d..c891c4e 100644
--- a/util.c
+++ b/util.c
@@ -164,7 +164,7 @@ addins(Ins **pvins, uint *pnins, Ins *i)
}
void
-addbins(Blk *b, Ins **pvins, uint *pnins)
+addbins(Ins **pvins, uint *pnins, Blk *b)
{
Ins *i;
@@ -281,6 +281,17 @@ igroup(Blk *b, Ins *i, Ins **i0, Ins **i1)
assert(i < ie);
*i1 = i + 1;
return;
+ case Osel1:
+ for (; i>ib && (i-1)->op == Osel1; i--)
+ ;
+ assert(i->op == Osel0);
+ /* fall through */
+ case Osel0:
+ *i0 = i++;
+ for (; i<ie && i->op == Osel1; i++)
+ ;
+ *i1 = i;
+ return;
default:
if (ispar(i->op))
goto case_Opar;