Ivan Llopard
2012-Feb-10 12:47 UTC
[LLVMdev] Remove redundant code after frame index elimination
Hi list, I added custom code to eliminate frame index references. I replace each FI reference with a subtraction from my frame pointer register (just like ebp in x86). Its result is stored in another register which is used by the load/store instructions. Nevertheless, this operation gives me redundant subs that I would like to remove after all fi references have been eliminated. For example: r = load fi<1> --> { sp = subm fi, cst_offset r = load sp } ... store fi<1>, val --> { sp = subm fi, cst_offset store sp, val } Any advice on what is the better solution to remove that code ? Should I create a custom pass after the prolog/epilog insertion one ? Ivan
Ivan Llopard
2012-Feb-13 10:22 UTC
[LLVMdev] Remove redundant code after frame index elimination
Hello again, I checked the sparc BE and I've seen that it adds also some MI when it eliminates FI references. Nevertheless, the testcase is very rare and it hardly happens in real applications but it can describe my problem. void test() { short a1; ... short a6003; a6000 = 2; a6000 = 3; } sethi 4194292, %g1 or %g1, 184, %g1 save %sp, %g1, %sp or %g0, 2, %l0 sethi 4194292, %g1 add %g1, %fp, %g1 sth %l0, [%g1+288] or %g0, 3, %l0 sethi 4194292, %g1 add %g1, %fp, %g1 sth %l0, [%g1+288] jmp %i7+8 restore %g0, %g0, %g0 Before the 2nd STH instruction, redundant code is added by the FI elimination routine (%g1 was already defined with the same value). My target does not have an addressing mode to represent fp + offset, so I need to store the result in an intermediate register to access the memory. It seems to me that the FI abstract model implies an indexed absolute addressing support provided by the target. Do I need to rely in early optimizations phases to avoid this kind of cases ? or, Is there a way to lower the FI node to extract its offset and write an explicit add operation ? I found that at the target lowering phase, no FI offset is represented for different variables (it's just a slot). It's defined at the FI elimination phase though. I could not find a way to lower it because of that. Please, any help would be appreciated. Regards, Ivan Le 10/02/2012 13:47, Ivan Llopard a écrit :> Hi list, > > I added custom code to eliminate frame index references. I replace > each FI reference with a subtraction from my frame pointer register > (just like ebp in x86). Its result is stored in another register which > is used by the load/store instructions. Nevertheless, this operation > gives me redundant subs that I would like to remove after all fi > references have been eliminated. For example: > > r = load fi<1> --> > { > sp = subm fi, cst_offset > r = load sp > } > ... > store fi<1>, val --> > { > sp = subm fi, cst_offset > store sp, val > } > > Any advice on what is the better solution to remove that code ? Should > I create a custom pass after the prolog/epilog insertion one ? > > Ivan
Maybe Matching Threads
- [LLVMdev] Solaris (sparc) llc bugs
- [LLVMdev] A question of Sparc assembly generated by llc
- [LLVMdev] Modifying the patterns/ instruction selection phase in LLVM 2.7
- [LLVMdev] Modifying the patterns/ instruction selection phase in LLVM 2.7
- [LLVMdev] Modifying the patterns/ instruction selection phase in LLVM 2.7