mirror of
https://github.com/danog/ir.git
synced 2024-11-30 04:39:43 +01:00
Fixed incorrect folding of sybolic constants
This commit is contained in:
parent
b9647172c2
commit
9d3854d787
14
ir_fold.h
14
ir_fold.h
@ -1880,7 +1880,7 @@ IR_FOLD(ADD(ADD, C_U32))
|
||||
IR_FOLD(ADD(ADD, C_U64))
|
||||
IR_FOLD(ADD(ADD, C_ADDR))
|
||||
{
|
||||
if (IR_IS_CONST_REF(op1_insn->op2)) {
|
||||
if (IR_IS_CONST_REF(op1_insn->op2) && !IR_IS_SYM_CONST(ctx->ir_base[op1_insn->op2].op)) {
|
||||
/* (x + c1) + c2 => x + (c1 + c2) */
|
||||
val.u64 = ctx->ir_base[op1_insn->op2].val.u64 + op2_insn->val.u64;
|
||||
op1 = op1_insn->op1;
|
||||
@ -1895,7 +1895,7 @@ IR_FOLD(ADD(ADD, C_I16))
|
||||
IR_FOLD(ADD(ADD, C_I32))
|
||||
IR_FOLD(ADD(ADD, C_I64))
|
||||
{
|
||||
if (IR_IS_CONST_REF(op1_insn->op2)) {
|
||||
if (IR_IS_CONST_REF(op1_insn->op2) && !IR_IS_SYM_CONST(ctx->ir_base[op1_insn->op2].op)) {
|
||||
/* (x + c1) + c2 => x + (c1 + c2) */
|
||||
val.i64 = ctx->ir_base[op1_insn->op2].val.i64 + op2_insn->val.i64;
|
||||
op1 = op1_insn->op1;
|
||||
@ -1910,7 +1910,7 @@ IR_FOLD(MUL(MUL, C_U16))
|
||||
IR_FOLD(MUL(MUL, C_U32))
|
||||
IR_FOLD(MUL(MUL, C_U64))
|
||||
{
|
||||
if (IR_IS_CONST_REF(op1_insn->op2)) {
|
||||
if (IR_IS_CONST_REF(op1_insn->op2) && !IR_IS_SYM_CONST(ctx->ir_base[op1_insn->op2].op)) {
|
||||
/* (x * c1) * c2 => x * (c1 * c2) */
|
||||
val.u64 = ctx->ir_base[op1_insn->op2].val.u64 * op2_insn->val.u64;
|
||||
op1 = op1_insn->op1;
|
||||
@ -1925,7 +1925,7 @@ IR_FOLD(MUL(MUL, C_I16))
|
||||
IR_FOLD(MUL(MUL, C_I32))
|
||||
IR_FOLD(MUL(MUL, C_I64))
|
||||
{
|
||||
if (IR_IS_CONST_REF(op1_insn->op2)) {
|
||||
if (IR_IS_CONST_REF(op1_insn->op2) && !IR_IS_SYM_CONST(ctx->ir_base[op1_insn->op2].op)) {
|
||||
/* (x * c1) * c2 => x * (c1 * c2) */
|
||||
val.i64 = ctx->ir_base[op1_insn->op2].val.i64 * op2_insn->val.i64;
|
||||
op1 = op1_insn->op1;
|
||||
@ -1944,7 +1944,7 @@ IR_FOLD(AND(AND, C_I16))
|
||||
IR_FOLD(AND(AND, C_I32))
|
||||
IR_FOLD(AND(AND, C_I64))
|
||||
{
|
||||
if (IR_IS_CONST_REF(op1_insn->op2)) {
|
||||
if (IR_IS_CONST_REF(op1_insn->op2) && !IR_IS_SYM_CONST(ctx->ir_base[op1_insn->op2].op)) {
|
||||
/* (x & c1) & c2 => x & (c1 & c2) */
|
||||
val.u64 = ctx->ir_base[op1_insn->op2].val.u64 & op2_insn->val.u64;
|
||||
op1 = op1_insn->op1;
|
||||
@ -1963,7 +1963,7 @@ IR_FOLD(OR(OR, C_I16))
|
||||
IR_FOLD(OR(OR, C_I32))
|
||||
IR_FOLD(OR(OR, C_I64))
|
||||
{
|
||||
if (IR_IS_CONST_REF(op1_insn->op2)) {
|
||||
if (IR_IS_CONST_REF(op1_insn->op2) && !IR_IS_SYM_CONST(ctx->ir_base[op1_insn->op2].op)) {
|
||||
/* (x | c1) | c2 => x | (c1 | c2) */
|
||||
val.u64 = ctx->ir_base[op1_insn->op2].val.u64 | op2_insn->val.u64;
|
||||
op1 = op1_insn->op1;
|
||||
@ -1982,7 +1982,7 @@ IR_FOLD(XOR(XOR, C_I16))
|
||||
IR_FOLD(XOR(XOR, C_I32))
|
||||
IR_FOLD(XOR(XOR, C_I64))
|
||||
{
|
||||
if (IR_IS_CONST_REF(op1_insn->op2)) {
|
||||
if (IR_IS_CONST_REF(op1_insn->op2) && !IR_IS_SYM_CONST(ctx->ir_base[op1_insn->op2].op)) {
|
||||
/* (x ^ c1) ^ c2 => x ^ (c1 ^ c2) */
|
||||
val.u64 = ctx->ir_base[op1_insn->op2].val.u64 ^ op2_insn->val.u64;
|
||||
op1 = op1_insn->op1;
|
||||
|
Loading…
Reference in New Issue
Block a user