>commit e4a0824120939235e40277a57425a72fbfcd5b9b >Author: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> >Date: Sun Mar 26 19:35:14 2017 +0200 > > add table to "negate" some opcode > > Some optimizations transform an instruction opcode > into another. For example, it may be needed to know > the opcode corresponding to the negation of a comparison. > > This patch make this easy and flexible by adding a table > for the relation between opcodes. >+const struct opcode_table opcode_table[OP_LAST] = { >+ [OP_SET_EQ] = { .negate = OP_SET_NE, }, >+ [OP_SET_NE] = { .negate = OP_SET_EQ, }, >+ [OP_SET_LT] = { .negate = OP_SET_GE, }, >+ [OP_SET_LE] = { .negate = OP_SET_GT, }, >+ [OP_SET_GE] = { .negate = OP_SET_LT, }, >+ [OP_SET_GT] = { .negate = OP_SET_LE, }, >+ [OP_SET_B ] = { .negate = OP_SET_AE, }, >+ [OP_SET_BE] = { .negate = OP_SET_A , }, >+ [OP_SET_AE] = { .negate = OP_SET_B , }, >+ [OP_SET_A ] = { .negate = OP_SET_BE, }, >+}; I think this patch ideally should be combined with the next patch. As it is, this patch is not self contain. There is no user of this table. >commit b38e2263075d1caa7694f47cc5f1cc8d78a2871d >Author: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> >Date: Mon Mar 27 17:19:43 2017 +0200 > > use opcode table for compare_opcode() > > At the same time, change also the name of the function. > ... > static int simplify_seteq_setne(struct instruction *insn, long long value) > { > pseudo_t old = insn->src1; >@@ -484,7 +460,7 @@ static int simplify_seteq_setne(struct instruction *insn, long long value) > // and similar for setne/eq ... 0/1 > src1 = def->src1; > src2 = def->src2; >- insn->opcode = compare_opcode(opcode, inverse); >+ insn->opcode = inverse ? opcode_table[opcode].negate : opcode; I think it would be better to have some kind of assert check here, the opcode you swap from the table is indeep opcode. Because you assign the opcode array using sparse index. It is easy to miss a spot creating the empty slot in the table. Also, the opcode table might be able to compressed only contain section of the BINCMP opcodes. Chris -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html