-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
58 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "../opt.h" | ||
|
||
OPT_PASS void vx_opt_ll_binary(vx_IrBlock *block) { | ||
for (vx_IrOp* op = block->first; op; op = op->next) { | ||
switch (op->id) { | ||
case VX_IR_OP_EQ: | ||
case VX_IR_OP_NEQ: | ||
case VX_IR_OP_AND: | ||
case VX_IR_OP_OR: | ||
case VX_IR_OP_BITWISE_AND: | ||
case VX_IR_OP_BITIWSE_OR: | ||
|
||
case VX_IR_OP_ADD: // TODO: this might break programs ; add safeadd and safemul that don't have this problem | ||
case VX_IR_OP_MUL: | ||
{ | ||
vx_IrValue *a = vx_IrOp_param(op, VX_IR_NAME_OPERAND_A); | ||
vx_IrValue *b = vx_IrOp_param(op, VX_IR_NAME_OPERAND_B); | ||
vx_IrVar ov = op->outs[0].var; | ||
|
||
if (b->type == VX_IR_VAL_VAR && b->var == ov) { | ||
vx_IrValue temp = *b; | ||
*b = *a; | ||
*a = temp; | ||
} | ||
} break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
} |