diff mbox

Refine type conversion in result expressions for cond_expr pattern

Message ID VI1PR0802MB2176342230684BDB6B782385E7B70@VI1PR0802MB2176.eurprd08.prod.outlook.com
State New
Headers show

Commit Message

Bin Cheng Nov. 23, 2016, 1:54 p.m. UTC
Hi,
This is actually the review suggestion for patch @https://gcc.gnu.org/ml/gcc-patches/2016-11/msg02341.html, but I forgot to incorporate it when committing that patch.  Here comes this one doing that, as well as adding a missing convert keyword.  Toolchain built successfully, is it OK?

Thanks,
bin

2016-11-23  Bin Cheng  <bin.cheng@arm.com>

	* match.pd: Refine type conversion in result expressions for below
	pattern:
	(cond (cmp (convert1? x) c1) (convert2? x) c2) -> (minmax (x c)).

Comments

Richard Biener Nov. 23, 2016, 2:27 p.m. UTC | #1
On Wed, Nov 23, 2016 at 2:54 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> This is actually the review suggestion for patch @https://gcc.gnu.org/ml/gcc-patches/2016-11/msg02341.html, but I forgot to incorporate it when committing that patch.  Here comes this one doing that, as well as adding a missing convert keyword.  Toolchain built successfully, is it OK?

As said you _do_ need the outermost (convert ...) on the (max .. and
(min ... expressions given @1 may not be of type 'type'.

> Thanks,
> bin
>
> 2016-11-23  Bin Cheng  <bin.cheng@arm.com>
>
>         * match.pd: Refine type conversion in result expressions for below
>         pattern:
>         (cond (cmp (convert1? x) c1) (convert2? x) c2) -> (minmax (x c)).
diff mbox

Patch

Index: gcc/match.pd
===================================================================
--- gcc/match.pd	(revision 242751)
+++ gcc/match.pd	(working copy)
@@ -2022,11 +2022,11 @@  DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
        }
    }
    (if (code == MAX_EXPR)
-    (convert (max @1 (convert:from_type @2)))
+    (max @1 (convert @2))
     (if (code == MIN_EXPR)
-     (convert (min @1 (convert:from_type @2)))
+     (min @1 (convert @2))
      (if (code == EQ_EXPR)
-      (cond (cmp @1 (convert:from_type @3)) (convert:from_type @3) @2)))))))
+      (cond (cmp @1 (convert @3)) (convert @3) (convert @2))))))))
 
 (for cnd (cond vec_cond)
  /* A ? B : (A ? X : C) -> A ? B : C.  */