To solve the above issue, can I use the "define_peephole2" insn pattern?No. At most you could abuse it to hide the issue some of the time. You probably have one or more of your target macros / hooks wrong, e.g. HARD_REGNO_NREGS.
Thank you very much for your reply. In my case, code generation is correctfor all test cases without optimization option. Wrong code generated (as mentioned in previous mail) for rare case with optimization + PIC options (ie -O1 -fPIC) enabled only.
Thanks Swami