Hi Ian, Thanks for your comments. It's not exactly the entire basic block. It should be from the current RTL to the end of the current basic block. As you know GCC will optimize "addl %ebx, %eax" to "leal (%ebx, %eax), %eax" to avoid the flag register dependency through a splitter in i386.md at split2 stage. But for my target, if the destination register of ADD actually holds non-address operand, which means "%eax" won't be used in MEM of the following RTL, this optimization will incur two cycles penalty. So I need to check whether the destination of ADD holds an address operands to decide whether split ADD to LEA.
Thanks Xuepeng Guo -----Original Message----- From: Ian Lance Taylor [mailto:i...@google.com] Sent: 2008年12月17日 15:08 To: Guo, Xuepeng Cc: gcc@gcc.gnu.org; Lu, Hongjiu; Ye, Joey; Lin, Weiliang Subject: Re: How can I determine a register is referred through MEM at split2 stage? "Guo, Xuepeng" <xuepeng....@intel.com> writes: > I am working on an optimization which happens at split2 stage. I > need to determine whether the destination operand of the current RTL > (which is a register operand) will be referred by other RTL through > MEM within a basic block. I see there is a function named > reg_mentioned_p (const_rtx reg, const_rtx in) in rtlanal.c to show > whether REG appears somewhere within IN. It does help except that it > can't tell me whether IN refers REG through MEM. Can anyone give me > some suggestions? You're going to have to write your own walker. There isn't any generic code for this. Are you sure you've described what you want? It sounds sort of strange. Why should you care about an entire basic block and only a basic block? Ian