This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/52352] [x32] - Wrong code to access addresses 0x80000000 to 0xFFFFFFFF using registers
- From: "ubizjak at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 24 Feb 2012 18:32:56 +0000
- Subject: [Bug target/52352] [x32] - Wrong code to access addresses 0x80000000 to 0xFFFFFFFF using registers
- Auto-submitted: auto-generated
- References: <bug-52352-4@http.gcc.gnu.org/bugzilla/>
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--