From b5f4f1508c5f7273b6d7859d6bb5320cddf7a3b1 Mon Sep 17 00:00:00 2001 From: Michael Collison Date: Thu, 25 Jun 2015 21:45:58 -0700 Subject: Transform end of loop conditions to min/max Change-Id: Ia056ff5f139301c18c5fc732a789a70f7613d267 --- gcc/ChangeLog | 8 +++++++- gcc/match.pd | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 49d8b6e2227..1da9946d121 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,10 @@ -2015-06-24 Michael Collison + Andrew Pinski + + * match.pd ((x < y) && (x < z) -> x < min (y,z), + (x > y) and (x > z) -> x > max (y,z)) + +2015-06-24 Michael Collison 2012-05-01 Ramana Radhakrishnan diff --git a/gcc/match.pd b/gcc/match.pd index 9c88e3eee39..f6c4833aed5 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1244,3 +1244,16 @@ along with GCC; see the file COPYING3. If not see (convert (bit_and (op (convert:utype @0) (convert:utype @1)) (convert:utype @4))))))) +/* Transform (@0 < @1 and @0 < @2) to use min */ +(for op (lt le) +(simplify +(bit_and:c (op @0 @1) (op @0 @2)) +(if (INTEGRAL_TYPE_P (TREE_TYPE (@0))) +(op @0 (min @1 @2))))) + +/* Transform (@0 > @1 and @0 > @2) to use max */ +(for op (gt ge) +(simplify +(bit_and:c (op @0 @1) (op @0 @2)) +(if (INTEGRAL_TYPE_P (TREE_TYPE (@0))) +(op @0 (max @1 @2))))) -- cgit v1.2.3