Commit 83ad4fac by Jeff Law Committed by Jeff Law

re PR target/25128 ([m68k] Suboptimal comparisons against 65536)

	PR target/25128
	* config/m68k/predicates.md (swap_peephole_relational_operator): New
	predicate.
	* config/m68k/m68k.md (relational tests against 65535/65536): New
	peephole2.

	PR target/25128
	* gcc.target/m68k/pr25128.c: New test.

From-SVN: r242676
parent 207a08cd
2016-11-20 Jeff Law <law@redhat.com>
PR target/25128
* config/m68k/predicates.md (swap_peephole_relational_operator): New
predicate.
* config/m68k/m68k.md (relational tests against 65535/65536): New
peephole2.
2016-11-21 Kyrylo Tkachov <kyrylo.tkachov@arm.com> 2016-11-21 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
* tree-ssa-loop-prefetch.c: Delete FIXME after the includes. * tree-ssa-loop-prefetch.c: Delete FIXME after the includes.
...@@ -7786,7 +7786,6 @@ ...@@ -7786,7 +7786,6 @@
operands[6] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1)); operands[6] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
operands[7] = operands[2]; operands[7] = operands[2];
}") }")
(define_peephole2 (define_peephole2
[(set (cc0) (compare (match_operand:SI 0 "register_operand" "") [(set (cc0) (compare (match_operand:SI 0 "register_operand" "")
(match_operand:SI 1 "pow2_m1_operand" ""))) (match_operand:SI 1 "pow2_m1_operand" "")))
...@@ -7804,3 +7803,23 @@ ...@@ -7804,3 +7803,23 @@
(match_dup 2) (match_dup 3)))] (match_dup 2) (match_dup 3)))]
"{ operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1)); }") "{ operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1)); }")
;; When optimizing for size or for the original 68000 or 68010, we can
;; improve some relational tests against 65536 (which get canonicalized
;; internally against 65535).
;; The rotate in the output pattern will turn into a swap.
(define_peephole2
[(set (cc0) (compare (match_operand:SI 0 "register_operand" "")
(const_int 65535)))
(set (pc) (if_then_else (match_operator 1 "swap_peephole_relational_operator"
[(cc0) (const_int 0)])
(match_operand 2 "pc_or_label_operand")
(match_operand 3 "pc_or_label_operand")))]
"peep2_reg_dead_p (1, operands[0])
&& (operands[2] == pc_rtx || operands[3] == pc_rtx)
&& (optimize_size || TUNE_68000_10)
&& DATA_REG_P (operands[0])"
[(set (match_dup 0) (rotate:SI (match_dup 0) (const_int 16)))
(set (cc0) (compare (subreg:HI (match_dup 0) 2) (const_int 0)))
(set (pc) (if_then_else (match_op_dup 1 [(cc0) (const_int 0)])
(match_dup 2) (match_dup 3)))]
"")
...@@ -279,3 +279,6 @@ ...@@ -279,3 +279,6 @@
;; Used to detect (pc) or (label_ref) in some jumping patterns to cut down ;; Used to detect (pc) or (label_ref) in some jumping patterns to cut down
(define_predicate "pc_or_label_operand" (define_predicate "pc_or_label_operand"
(match_code "pc,label_ref")) (match_code "pc,label_ref"))
(define_predicate "swap_peephole_relational_operator"
(match_code "gtu,leu,gt,le"))
2016-11-20 Jeff Law <law@redhat.com>
PR target/25128
* gcc.target/m68k/pr25128.c: New test.
2016-11-21 Richard Sandiford <richard.sandiford@arm.com> 2016-11-21 Richard Sandiford <richard.sandiford@arm.com>
* gcc.dg/tree-ssa/tailcall-7.c: New test. * gcc.dg/tree-ssa/tailcall-7.c: New test.
......
/* { dg-do compile } */
/* { dg-options "-Os" } */
/* { dg-final { scan-assembler-times "swap" 4 } } */
/* { dg-final { scan-assembler-times "tst.w" 4 } } */
/* { dg-final { scan-assembler-not "cmp.l" } } */
unsigned int bar (void);
void
foo1 (void)
{
unsigned int a = bar ();
if (0x10000 <= a)
bar ();
}
void
foo2 (void)
{
unsigned int a = bar ();
if (0x10000 > a)
bar ();
}
void
foo3 (void)
{
int a = bar ();
if (0x10000 <= a)
bar ();
}
void
foo4 (void)
{
int a = bar ();
if (0x10000 > a)
bar ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment