From patchwork Tue Jul 26 17:26:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: PATCH: PR target/49853: [x32] PIC doesn't work with external symbol Date: Tue, 26 Jul 2011 07:26:09 -0000 From: Uros Bizjak X-Patchwork-Id: 106898 Message-Id: To: "H.J. Lu" Cc: gcc-patches@gcc.gnu.org On Tue, Jul 26, 2011 at 4:59 PM, H.J. Lu wrote: > This patch fixes PIC with external symbol and updates > x86_64_immediate_operand/x86_64_zext_immediate_operand/x86_64_movabs_operand > for x32. > 2011-07-26  H.J. Lu   > >        PR target/49853 >        * config/i386/i386.c (ix86_expand_move): Call convert_to_mode >        on legitimize_tls_address return if needed.  Allow ptr_mode for >        symbolic operand with PIC. Eh... half of your patch is just an unnecessary rename of a temporary variable. See attached patch for a cleaned-up version. Also, please use explicit DImode and SImode checks to match what ix86_legitimate_address_p does. >        * config/i386/predicates.md (x86_64_immediate_operand): Always >        allow the offsetted memory references for TARGET_X32. >        (x86_64_zext_immediate_operand): Likewise. >        (x86_64_movabs_operand): Don't allow nonmemory_operand for >        TARGET_X32. Why? It is certainly not needed for -fPIC. Please provide a separate patch and testcase for predicates.md change. Uros. Index: i386.c =================================================================== --- i386.c (revision 176794) +++ i386.c (working copy) @@ -15028,11 +15028,14 @@ ix86_expand_move (enum machine_mode mode op0, 1, OPTAB_DIRECT); if (tmp == op0) return; + if (GET_MODE (tmp) != mode) + op1 = convert_to_mode (mode, tmp, 1); } } if ((flag_pic || MACHOPIC_INDIRECT) - && mode == Pmode && symbolic_operand (op1, Pmode)) + && (mode == SImode || mode == DImode) + && symbolic_operand (op1, mode)) { if (TARGET_MACHO && !TARGET_64BIT) { @@ -15073,13 +15076,15 @@ ix86_expand_move (enum machine_mode mode else { if (MEM_P (op0)) - op1 = force_reg (Pmode, op1); - else if (!TARGET_64BIT || !x86_64_movabs_operand (op1, Pmode)) + op1 = force_reg (mode, op1); + else if (!TARGET_64BIT || !x86_64_movabs_operand (op1, mode)) { rtx reg = can_create_pseudo_p () ? NULL_RTX : op0; op1 = legitimize_pic_address (op1, reg); if (op0 == op1) return; + if (GET_MODE (op1) != mode) + op1 = convert_to_mode (mode, op1, 1); } } }