]> de.git.xonotic.org Git - xonotic/gmqcc.git/commit
ir: fix generation of multi-op vinstrs
authorWolfgang Bumiller <wry.git@bumiller.com>
Sun, 15 Sep 2019 08:07:06 +0000 (10:07 +0200)
committerWolfgang Bumiller <wry.git@bumiller.com>
Sun, 15 Sep 2019 08:23:47 +0000 (10:23 +0200)
commit2d4a054440e9fdf12edc202188ae4ea2e4ce90b5
tree6f532ac6946066f669377bba3b012ad588773a45
parent031f827da5457ed969bbf66e520105f9600a1229
ir: fix generation of multi-op vinstrs

Do not assume that the destination is a temporary location,
as our peephole optimizer will break this. For example, the
following IR code (generated via from `x ^= gety()`):

    (0) binst6 <- BITXOR   x,      call5
    (0) x <- STORE_F       binst6

after peephole optimization becomes:

    (7) x <- BITXOR        x,      call5

Therefore we cannot assume that the output of the virtual
xor instruction can be utilized as a temporary value.

BITXOR becomes `(x | y) - (x & y)`, which would wrongly be
generated as:
    x = x | y;
    temp0 = x & y;
    x = x - temp0;

While this particular case can be fixed by using temp0 first
and then x, the cross-product case would not be so simple.

Signed-off-by: Wolfgang Bumiller <wry.git@bumiller.com>
Fixes #190
ir.cpp