This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] SPARC andcc patterns
- To: "David S. Miller" <davem at redhat dot com>
- Subject: [PATCH] SPARC andcc patterns
- From: Jakub Jelinek <jakub at redhat dot com>
- Date: Mon, 27 Dec 1999 12:08:17 +0100
- Cc: gcc-patches at gcc dot gnu dot org
Hi!
This patch makes code like
void foo(long b)
{
if ((b & 0xff) == 0)
bar();
}
be optimized again (it used to work, but e.g. egcs 1.1.2 did not optimize
this already and neither does 2.96).
If this patch is applied after SUBREG_BYTE patches, one has to adjust subreg
offsets from 0 to 3 resp. 7.
1999-12-27 Jakub Jelinek <jakub@redhat.com>
* config/sparc/sparc.md (cmp_zero_qi,
cmp_zero_extendqisi2_andcc_set, cmp_zero_qi_sp64,
cmp_zero_extendqidi2_andcc_set): New patterns.
--- gcc/config/sparc/sparc.md.jj Mon Dec 13 02:20:07 1999
+++ gcc/config/sparc/sparc.md Mon Dec 27 11:47:58 1999
@@ -4489,6 +4489,15 @@
[(set_attr "type" "compare")
(set_attr "length" "1")])
+(define_insn "*cmp_zero_qi"
+ [(set (reg:CC 100)
+ (compare:CC (match_operand:QI 0 "register_operand" "r")
+ (const_int 0)))]
+ "! TARGET_LIVE_G0"
+ "andcc\\t%0, 0xff, %%g0"
+ [(set_attr "type" "compare")
+ (set_attr "length" "1")])
+
(define_insn "*cmp_zero_extendqisi2_set"
[(set (reg:CC 100)
(compare:CC (zero_extend:SI (match_operand:QI 1 "register_operand" "r"))
@@ -4500,6 +4509,18 @@
[(set_attr "type" "compare")
(set_attr "length" "1")])
+(define_insn "*cmp_zero_extendqisi2_andcc_set"
+ [(set (reg:CC 100)
+ (compare:CC (and:SI (match_operand:SI 1 "register_operand" "r")
+ (const_int 255))
+ (const_int 0)))
+ (set (match_operand:SI 0 "register_operand" "=r")
+ (zero_extend:SI (subreg:QI (match_dup 1) 0)))]
+ ""
+ "andcc\\t%1, 0xff, %0"
+ [(set_attr "type" "compare")
+ (set_attr "length" "1")])
+
(define_insn "*cmp_zero_extendqidi2"
[(set (reg:CCX 100)
(compare:CCX (zero_extend:DI (match_operand:QI 0 "register_operand" "r"))
@@ -4509,12 +4530,33 @@
[(set_attr "type" "compare")
(set_attr "length" "1")])
+(define_insn "*cmp_zero_qi_sp64"
+ [(set (reg:CCX 100)
+ (compare:CCX (match_operand:QI 0 "register_operand" "r")
+ (const_int 0)))]
+ "TARGET_ARCH64"
+ "andcc\\t%0, 0xff, %%g0"
+ [(set_attr "type" "compare")
+ (set_attr "length" "1")])
+
(define_insn "*cmp_zero_extendqidi2_set"
[(set (reg:CCX 100)
(compare:CCX (zero_extend:DI (match_operand:QI 1 "register_operand" "r"))
(const_int 0)))
(set (match_operand:DI 0 "register_operand" "=r")
(zero_extend:DI (match_dup 1)))]
+ "TARGET_ARCH64"
+ "andcc\\t%1, 0xff, %0"
+ [(set_attr "type" "compare")
+ (set_attr "length" "1")])
+
+(define_insn "*cmp_zero_extendqidi2_andcc_set"
+ [(set (reg:CCX 100)
+ (compare:CCX (and:DI (match_operand:DI 1 "register_operand" "r")
+ (const_int 255))
+ (const_int 0)))
+ (set (match_operand:DI 0 "register_operand" "=r")
+ (zero_extend:DI (subreg:QI (match_dup 1) 0)))]
"TARGET_ARCH64"
"andcc\\t%1, 0xff, %0"
[(set_attr "type" "compare")
Cheers,
Jakub
___________________________________________________________________
Jakub Jelinek | jakub@redhat.com | http://sunsite.mff.cuni.cz/~jj
Linux version 2.3.34 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________