Commit 8f63caf6 by Richard Biener Committed by Prathamesh Kulkarni

re PR middle-end/70920 (if ((intptr_t)ptr == 0) doesn't get simplified to if (ptr == 0))

2016-07-26  Richard Biener  <rguenther@suse.de>
	    Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>

	PR middle-end/70920
	* match.pd ((intptr)x eq/ne CST to x eq/ne (typeof x) CST): New
	pattern.

testsuite/
	* gcc.dg/pr70920-1.c: New test-case.
	* gcc.dg/pr70902-2.c: Likewise.
	* gcc.dg/pr70920-3.c: Likewise.
	* gcc.dg/pr70920-4.c: Likewise
	* gcc.dg/tree-ssa/ssa-dom-branch-1.c: Change scan-tree-dump-times to
	2 instead of 3.

Co-Authored-By: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>

From-SVN: r238754
parent c4f82055
2016-07-26 Richard Biener <rguenther@suse.de>
Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR middle-end/70920
* match.pd ((intptr)x eq/ne CST to x eq/ne (typeof x) CST): New
pattern.
2016-07-26 Trevor Saunders <tbsaunde+gcc@tbsaunde.org> 2016-07-26 Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
* tree-ssa-structalias.c (struct scc_info): Change types of * tree-ssa-structalias.c (struct scc_info): Change types of
......
...@@ -2513,6 +2513,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) ...@@ -2513,6 +2513,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
&& ptrs_compare_unequal (@0, @1)) && ptrs_compare_unequal (@0, @1))
{ neeq == EQ_EXPR ? boolean_false_node : boolean_true_node; }))) { neeq == EQ_EXPR ? boolean_false_node : boolean_true_node; })))
/* PR70920: Transform (intptr_t)x eq/ne CST to x eq/ne (typeof x) CST.
and (typeof ptr_cst) x eq/ne ptr_cst to x eq/ne (typeof x) CST */
(for cmp (ne eq)
(simplify
(cmp (convert @0) INTEGER_CST@1)
(if ((POINTER_TYPE_P (TREE_TYPE (@0)) && INTEGRAL_TYPE_P (TREE_TYPE (@1)))
|| (INTEGRAL_TYPE_P (TREE_TYPE (@0)) && POINTER_TYPE_P (TREE_TYPE (@1))))
(cmp @0 (convert @1)))))
/* Non-equality compare simplifications from fold_binary */ /* Non-equality compare simplifications from fold_binary */
(for cmp (lt gt le ge) (for cmp (lt gt le ge)
/* Comparisons with the highest or lowest possible integer of /* Comparisons with the highest or lowest possible integer of
......
2016-07-26 Richard Biener <rguenther@suse.de>
Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR middle-end/70920
* gcc.dg/pr70920-1.c: New test-case.
* gcc.dg/pr70902-2.c: Likewise.
* gcc.dg/pr70920-3.c: Likewise.
* gcc.dg/pr70920-4.c: Likewise
* gcc.dg/tree-ssa/ssa-dom-branch-1.c: Change scan-tree-dump-times to
2 instead of 3.
2016-07-25 Alexander Monakov <amonakov@ispras.ru> 2016-07-25 Alexander Monakov <amonakov@ispras.ru>
* gcc.c-torture/execute/pr71494.c: Require label_values. * gcc.c-torture/execute/pr71494.c: Require label_values.
......
/* { dg-do compile } */
/* { dg-options "-fdump-tree-gimple" } */
#include <stdint.h>
void f1();
void f2();
void
foo (int *a)
{
if ((intptr_t) a == 0)
{
f1 ();
if (a)
f2 ();
}
}
/* { dg-final { scan-tree-dump "if \\(a == 0B\\)" "gimple" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-forwprop-details" } */
#include <stdint.h>
void f1();
void f2();
void
foo (int *a)
{
int cst = 0;
if ((intptr_t) a == cst)
{
f1 ();
if (a)
f2 ();
}
}
/* { dg-final { scan-tree-dump "gimple_simplified to if \\(a_\[0-9\]*\\(D\\) == 0B\\)" "forwprop1" } } */
/* { dg-do compile } */
/* { dg-options "-fdump-tree-gimple -Wno-int-to-pointer-cast" } */
#include <stdint.h>
void f1();
void f2();
void
foo (int a)
{
if ((int *) a == 0)
{
f1 ();
if (a)
f2 ();
}
}
/* { dg-final { scan-tree-dump "if \\(a == 0\\)" "gimple" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-ccp-details -Wno-int-to-pointer-cast" } */
#include <stdint.h>
void f1();
void f2();
void
foo (int a)
{
void *cst = 0;
if ((int *) a == cst)
{
f1 ();
if (a)
f2 ();
}
}
/* { dg-final { scan-tree-dump "gimple_simplified to if \\(_\[0-9\]* == 0\\)" "ccp1" } } */
...@@ -19,9 +19,9 @@ try_combine (rtx i1, rtx newpat) ...@@ -19,9 +19,9 @@ try_combine (rtx i1, rtx newpat)
else if (i1 && foo ()); else if (i1 && foo ());
} }
/* There should be three tests against i1. Two from the hash table /* There should be two tests against i1. One from the hash table
dumps, one in the code itself. */ dumps, one in the code itself. */
/* { dg-final { scan-tree-dump-times "if .i1_" 3 "dom2"} } */ /* { dg-final { scan-tree-dump-times "if .i1_" 2 "dom2"} } */
/* There should be no actual jump threads realized by DOM. The /* There should be no actual jump threads realized by DOM. The
legitimize jump threads are handled in VRP and those discovered legitimize jump threads are handled in VRP and those discovered
......
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