aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg-Johann Lay <avr@gjlay.de>2011-06-21 17:30:54 +0000
committerGeorg-Johann Lay <gjl@gcc.gnu.org>2011-06-21 17:30:54 +0000
commit663827d3e5b2ae5fdbcc8b2b6591910b886af3b2 (patch)
treef4cb0e57d5b8a47d649a75d10793b2a90a0bd8c1
parent61d2c24233c52c2440cd285a3c3e97025fd6a7b9 (diff)
downloadgcc-663827d3e5b2ae5fdbcc8b2b6591910b886af3b2.zip
gcc-663827d3e5b2ae5fdbcc8b2b6591910b886af3b2.tar.gz
gcc-663827d3e5b2ae5fdbcc8b2b6591910b886af3b2.tar.bz2
re PR target/33049 ([avr] bit extraction non optimal, inversing logic solves problem)
PR target/33049 * config/avr/avr.md (extzv): New expander. (*extzv): New insn. (*extzv.qihi1, *extzv.qihi2): New insn-and-split. * config/avr/constraints.md (C04): New constraint. * doc/md.texi (Machine Constraints): Document it. From-SVN: r175269
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/config/avr/avr.md62
-rw-r--r--gcc/config/avr/constraints.md5
-rw-r--r--gcc/doc/md.texi3
4 files changed, 79 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index db3b00b..3e0d8ac 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2011-06-21 Georg-Johann Lay <avr@gjlay.de>
+
+ PR target/33049
+ * config/avr/avr.md (extzv): New expander.
+ (*extzv): New insn.
+ (*extzv.qihi1, *extzv.qihi2): New insn-and-split.
+ * config/avr/constraints.md (C04): New constraint.
+ * doc/md.texi (Machine Constraints): Document it.
+
2011-06-21 Jakub Jelinek <jakub@redhat.com>
PR middle-end/49489
diff --git a/gcc/config/avr/avr.md b/gcc/config/avr/avr.md
index 4d77b0e..0e5031c 100644
--- a/gcc/config/avr/avr.md
+++ b/gcc/config/avr/avr.md
@@ -3539,3 +3539,65 @@
int byteno = INTVAL(operands[2]) / BITS_PER_UNIT;
operands[4] = simplify_gen_subreg (QImode, operands[0], <MODE>mode, byteno);
})
+
+(define_expand "extzv"
+ [(set (match_operand:QI 0 "register_operand" "")
+ (zero_extract:QI (match_operand:QI 1 "register_operand" "")
+ (match_operand:QI 2 "const1_operand" "")
+ (match_operand:QI 3 "const_0_to_7_operand" "")))]
+ ""
+ "")
+
+(define_insn "*extzv"
+ [(set (match_operand:QI 0 "register_operand" "=*d,*d,*d,*d,r")
+ (zero_extract:QI (match_operand:QI 1 "register_operand" "0,r,0,0,r")
+ (const_int 1)
+ (match_operand:QI 2 "const_0_to_7_operand" "L,L,P,C04,n")))]
+ ""
+ "@
+ andi %0,1
+ mov %0,%1\;andi %0,1
+ lsr %0\;andi %0,1
+ swap %0\;andi %0,1
+ bst %1,%2\;clr %0\;bld %0,0"
+ [(set_attr "length" "1,2,2,2,3")
+ (set_attr "cc" "set_zn,set_zn,set_zn,set_zn,clobber")])
+
+(define_insn_and_split "*extzv.qihi1"
+ [(set (match_operand:HI 0 "register_operand" "=r")
+ (zero_extract:HI (match_operand:QI 1 "register_operand" "r")
+ (const_int 1)
+ (match_operand:QI 2 "const_0_to_7_operand" "n")))]
+ ""
+ "#"
+ ""
+ [(set (match_dup 3)
+ (zero_extract:QI (match_dup 1)
+ (const_int 1)
+ (match_dup 2)))
+ (set (match_dup 4)
+ (const_int 0))]
+ {
+ operands[3] = simplify_gen_subreg (QImode, operands[0], HImode, 0);
+ operands[4] = simplify_gen_subreg (QImode, operands[0], HImode, 1);
+ })
+
+(define_insn_and_split "*extzv.qihi2"
+ [(set (match_operand:HI 0 "register_operand" "=r")
+ (zero_extend:HI
+ (zero_extract:QI (match_operand:QI 1 "register_operand" "r")
+ (const_int 1)
+ (match_operand:QI 2 "const_0_to_7_operand" "n"))))]
+ ""
+ "#"
+ ""
+ [(set (match_dup 3)
+ (zero_extract:QI (match_dup 1)
+ (const_int 1)
+ (match_dup 2)))
+ (set (match_dup 4)
+ (const_int 0))]
+ {
+ operands[3] = simplify_gen_subreg (QImode, operands[0], HImode, 0);
+ operands[4] = simplify_gen_subreg (QImode, operands[0], HImode, 1);
+ })
diff --git a/gcc/config/avr/constraints.md b/gcc/config/avr/constraints.md
index 2ac8833..e754c79 100644
--- a/gcc/config/avr/constraints.md
+++ b/gcc/config/avr/constraints.md
@@ -107,3 +107,8 @@
"A memory address based on Y or Z pointer with displacement."
(and (match_code "mem")
(match_test "extra_constraint_Q (op)")))
+
+(define_constraint "C04"
+ "Constant integer 4."
+ (and (match_code "const_int")
+ (match_test "ival == 4")))
diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi
index 65e4070..abe51f8 100644
--- a/gcc/doc/md.texi
+++ b/gcc/doc/md.texi
@@ -1773,6 +1773,9 @@ Integer constant in the range @minus{}6 @dots{} 5.
@item Q
A memory address based on Y or Z pointer with displacement.
+
+@item C04
+Constant integer 4
@end table
@item Hewlett-Packard PA-RISC---@file{config/pa/pa.h}