[PATCH, alpha]: Fix PR 22093, Unaligned access to HI values causes unrecognizable insn error
Uros Bizjak
ubizjak@gmail.com
Wed Sep 30 09:06:00 GMT 2009
Hello!
The problem is, that we expand unaligned access through:
[(set (match_operand:DI 3 "register_operand" "")
(mem:DI (and:DI (match_operand:DI 0 "address_operand" "")
(const_int -8))))
(set (match_operand:DI 2 "register_operand" "")
(plus:DI (match_dup 0) (const_int 1)))
where the first operand of plus RTX does not satisfy corresponding
insn predicate:
(define_insn "*adddi_internal"
[(set (match_operand:DI 0 "register_operand" "=r,r,r")
(plus:DI (match_operand:DI 1 "register_operand" "%r,r,r")
(match_operand:DI 2 "add_operand" "r,K,L")))]
So, we should force the operand of plus RTX into register.
Fixed gcc produces:
lda $2,2($31)
lda $1,x
lda $4,7($1)
ldq_u $3,6($1)
inswl $2,$4,$2
mskwl $3,$4,$3
bis $2,$3,$2
stq_u $2,6($1)
ret $31,($26),1
which is just what we expect.
Tested on alphaev68-pc-linux-gnu and by eyeballing generated code with #define
-------------- next part --------------
Index: config/alpha/alpha.md
===================================================================
--- config/alpha/alpha.md (revision 152321)
+++ config/alpha/alpha.md (working copy)
@@ -5861,7 +5861,7 @@
(mem:DI (and:DI (match_operand:DI 0 "address_operand" "")
(const_int -8))))
(set (match_operand:DI 2 "register_operand" "")
- (plus:DI (match_dup 0) (const_int 1)))
+ (plus:DI (match_dup 5) (const_int 1)))
(set (match_dup 3)
(and:DI (not:DI (ashift:DI
(const_int 65535)
@@ -5876,7 +5876,7 @@
(set (mem:DI (and:DI (match_dup 0) (const_int -8)))
(match_dup 4))]
"WORDS_BIG_ENDIAN"
- "")
+ "operands[5] = force_reg (DImode, operands[0]);")
;; Here are the define_expand's for QI and HI moves that use the above
;; patterns. We have the normal sets, plus the ones that need scratch
Index: testsuite/gcc.target/alpha/pr22093.c
===================================================================
--- testsuite/gcc.target/alpha/pr22093.c (revision 0)
+++ testsuite/gcc.target/alpha/pr22093.c (revision 152322)
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+struct shared_ptr_struct
+{
+ unsigned long phase : 48;
+ unsigned thread : 16;
+ void *addr;
+} x;
+
+void foo (void)
+{
+ x.thread = 2;
+}
More information about the Gcc-patches
mailing list