diff mbox

[PATCH/VRP] Fix type of EQ_EXPR

Message ID CA+=Sn1nxrDoOCkyDuLwaGaXrFrK-ocTadD-uueF5Zp8taKD5jw@mail.gmail.com
State New
Headers show

Commit Message

Andrew Pinski Nov. 29, 2016, 6:36 a.m. UTC
While rewriting PHI-OPT to use match and simplify infrastructure, I
ran into a problem where VRP pass would create a EQ_EXPR which has a
non boolean type inside the VRP pass.  This currently works on
accident as it seems we don't check the type of the argument of
COND_EXPR gimple to be boolean type if it is a comparison.

OK?  Bootstrapped and tested on aarch64-linux-gnu with no regressions.

Thanks,
Andrew Pinski

ChangeLog:
* tree-vrp.c (simplify_stmt_using_ranges): Use boolean_type_node
for the EQ_EXPR.

Comments

Richard Biener Nov. 29, 2016, 10:26 a.m. UTC | #1
On Tue, Nov 29, 2016 at 7:36 AM, Andrew Pinski <pinskia@gmail.com> wrote:
> While rewriting PHI-OPT to use match and simplify infrastructure, I
> ran into a problem where VRP pass would create a EQ_EXPR which has a
> non boolean type inside the VRP pass.  This currently works on
> accident as it seems we don't check the type of the argument of
> COND_EXPR gimple to be boolean type if it is a comparison.
>
> OK?  Bootstrapped and tested on aarch64-linux-gnu with no regressions.

Ok.

Richard.

> Thanks,
> Andrew Pinski
>
> ChangeLog:
> * tree-vrp.c (simplify_stmt_using_ranges): Use boolean_type_node
> for the EQ_EXPR.
diff mbox

Patch

Index: tree-vrp.c
===================================================================
--- tree-vrp.c	(revision 242933)
+++ tree-vrp.c	(working copy)
@@ -10225,7 +10225,7 @@  simplify_stmt_using_ranges (gimple_stmt_
 	     in divide by zero, new_rhs1 / new_rhs will be NULL_TREE.  */
 	  if (new_rhs1 && new_rhs2)
 	    {
-	      tree cond = build2 (EQ_EXPR, TREE_TYPE (cmp_var), cmp_var, val1);
+	      tree cond = build2 (EQ_EXPR, boolean_type_node, cmp_var, val1);
 	      gimple_assign_set_rhs_with_ops (gsi,
 					      COND_EXPR, cond,
 					      new_rhs1,