This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Enable EBX for x86 in 32bits PIC code


On 2014-08-29 2:47 AM, Ilya Enkovich wrote:
Seems your patch doesn't cover all cases.  Attached is a modified
patch (with your changes included) and a test where double constant is
wrongly rematerialized.  I also see in ira dump that there is still a
copy of PIC reg created:

Initialization of original PIC reg:
(insn 23 22 24 2 (set (reg:SI 127)
         (reg:SI 3 bx)) test.cc:42 90 {*movsi_internal}
      (expr_list:REG_DEAD (reg:SI 3 bx)
         (nil)))
...
Copy is created:
(insn 135 37 25 3 (set (reg:SI 138 [127])
         (reg:SI 127)) 90 {*movsi_internal}
      (expr_list:REG_DEAD (reg:SI 127)
         (nil)))
...
Copy is used:
(insn 119 25 122 3 (set (reg:DF 134)
         (mem/u/c:DF (plus:SI (reg:SI 138 [127])
                 (const:SI (unspec:SI [
                             (symbol_ref/u:SI ("*.LC0") [flags 0x2])
                         ] UNSPEC_GOTOFF))) [5  S8 A64])) 128 {*movdf_internal}
      (expr_list:REG_EQUIV (const_double:DF
2.9999999999999997371893933895137251965934410691261292e-4
[0x0.9d495182a99308p-11])
         (nil)))


The copy is created by a newer IRA optimization for function prologues.

The patch in the attachment should solve the problem. I also added the code to prevent spilling the pic pseudo in LRA which could happen before theoretically.


After reload we have new usage of r127 which is allocated to ecx which
actually does not have any definition in this function at all.

(insn 151 42 44 4 (set (reg:SI 0 ax [147])
         (plus:SI (reg:SI 2 cx [127])
             (const:SI (unspec:SI [
                         (symbol_ref/u:SI ("*.LC0") [flags 0x2])
                     ] UNSPEC_GOTOFF)))) test.cc:44 213 {*leasi}
      (expr_list:REG_EQUAL (symbol_ref/u:SI ("*.LC0") [flags 0x2])
         (nil)))
(insn 44 151 45 4 (set (reg:DF 21 xmm0 [orig:129 D.2450 ] [129])
         (mult:DF (reg:DF 21 xmm0 [orig:128 D.2450 ] [128])
             (mem/u/c:DF (reg:SI 0 ax [147]) [5  S8 A64]))) test.cc:44
790 {*fop_df_comm_sse}
      (expr_list:REG_EQUAL (mult:DF (reg:DF 21 xmm0 [orig:128 D.2450 ] [128])
             (const_double:DF
2.9999999999999997371893933895137251965934410691261292e-4
[0x0.9d495182a99308p-11]))
         (nil)))

Compilation string: g++ -m32 -O2 -mfpmath=sse -fPIE -S test.cc

Attachment: z2
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]