http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52352

--- Comment #10 from Uros Bizjak <ubizjak at gmail dot com> 2012-02-24 18:32:56 
UTC ---
(In reply to comment #9)
> It is fixed on hjl/x32/addr32, hjl/x32/gcc-4_6-branch and
> hjl/x32/gcc-4_6-branch+mx32 branches.
> 
> The problem is
> 
> ;; Stores and loads of ax to arbitrary constant address.
> ;; We fake an second form of instruction to force reload to load address
> ;; into register when rax is not available
> (define_insn "*movabs<mode>_1"
>   [(set (mem:SWI1248x (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
>         (match_operand:SWI1248x 1 "nonmemory_operand" "a,er"))]
>   "TARGET_64BIT && ix86_check_movabs (insn, 0)"
>   "@
>    movabs{<imodesuffix>}\t{%1, %P0|%P0, %1}
>    mov{<imodesuffix>}\t{%1, %a0|%a0, %1}"
> 
> DImode is incorrect for x32, especially for register operand.
> That is where
> 
> movq    $-18874360, %rax
> movl    (%rax), %edx
> 
> comes from. It should be in Pmode. However, the immediate operand
> must be in DImode for x86_64_movabs_operand.

But this is the _address_ that we are talking, see the "MEM" RTX. So, following
(untested) patch can help - access is in PTR mode, and "a" modifier should
handle this without problems.

--cut here--
Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md (revision 184560)
+++ config/i386/i386.md (working copy)
@@ -2360,7 +2360,7 @@
 ;; We fake an second form of instruction to force reload to load address
 ;; into register when rax is not available
 (define_insn "*movabs<mode>_1"
-  [(set (mem:SWI1248x (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
+  [(set (mem:SWI1248x (match_operand:PTR 0 "x86_64_movabs_operand" "i,r"))
        (match_operand:SWI1248x 1 "nonmemory_operand" "a,er"))]
   "TARGET_64BIT && ix86_check_movabs (insn, 0)"
   "@
@@ -2375,7 +2375,7 @@

 (define_insn "*movabs<mode>_2"
   [(set (match_operand:SWI1248x 0 "register_operand" "=a,r")
-        (mem:SWI1248x (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
+        (mem:SWI1248x (match_operand:PTR 1 "x86_64_movabs_operand" "i,r")))]
   "TARGET_64BIT && ix86_check_movabs (insn, 1)"
   "@
    movabs{<imodesuffix>}\t{%P1, %0|%0, %P1}
--cut here--

Reply via email to