Hi Luc, On 19 March 2017 at 17:55, Dibyendu Majumdar <mobile@xxxxxxxxxxxxxxx> wrote: > On 19 March 2017 at 17:15, Luc Van Oostenryck > <luc.vanoostenryck@xxxxxxxxx> wrote: >> On Sun, Mar 19, 2017 at 5:37 PM, Dibyendu Majumdar >> <mobile@xxxxxxxxxxxxxxx> wrote: >>> On 19 March 2017 at 15:36, Luc Van Oostenryck >>> <luc.vanoostenryck@xxxxxxxxx> wrote: >>>> >>> I noticed that in the latest patch series for add/sub you are not >>> using GEP anymore, and there is a conversion to target type at the end >>> of a binary op. I will try out these changes and report back. >> >> Yes. It's not that the GEP was wrong but it was not enough and the more >> complete solution made this one unneeded. >> > > I have now tested the changes to binary op implementation - and I can > confirm that all my tests pass, and this appears to be a better > approach than the previous one that used the GEP instruction. > It seems that we can replace the other GEP too with pointer arithmetic. This makes LLVM output closer to the IR generated by sparse. The change required is in calc_memop_addr(): /* int type large enough to hold a pointer */ int_type = LLVMIntType(bits_in_pointer); /* IMPORTANT offset can be negative */ off = LLVMConstInt(int_type, (int) insn->offset, 0); /* convert src to the effective pointer type */ src = pseudo_to_value(fn, insn, insn->src); as = LLVMGetPointerAddressSpace(LLVMTypeOf(src)); addr_type = LLVMPointerType(insn_symbol_type(insn), as); src = value_to_ivalue(fn, src); addr = LLVMBuildAdd(fn->builder, src, off, ""); addr = LLVMBuildIntToPtr(fn->builder, addr, addr_type, ""); return addr; Regards Dibyendu -- 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