On 02/04/2016 07:30 AM, Richard Henderson wrote:
On 02/04/2016 12:46 AM, Richard Biener wrote:
As for a patch I'd repeatedly pondered on not stripping int <-> pointer
conversions at all, similar to what STRIP_SIGN_NOPS does. Don't remember
actually trying this or the fallout though.
I'll run that through a test cycle and see what happens.
+FAIL: c-c++-common/fold-bitand-4.c -Wc++-compat scan-tree-dump-times
original "& 15" 1
+FAIL: c-c++-common/fold-bitand-4.c -Wc++-compat scan-tree-dump-times
original "return [^\\n0-9]*0;" 2
+FAIL: c-c++-common/fold-bitand-4.c -Wc++-compat scan-tree-dump-times
original "return [^\\n0-9]*12;" 1
+FAIL: gcc.dg/fold-bitand-1.c scan-tree-dump-times original "&c4 & 3" 0
+FAIL: gcc.dg/fold-bitand-1.c scan-tree-dump-times original "&c8 & 3" 0
+FAIL: gcc.dg/fold-bitand-1.c scan-tree-dump-times original "return 0" 2
+FAIL: gcc.dg/fold-bitand-2.c scan-tree-dump-times original "& 3" 0
+FAIL: gcc.dg/fold-bitand-2.c scan-tree-dump-times original "return 0" 1
+FAIL: gcc.dg/fold-bitand-2.c scan-tree-dump-times original "return 1" 1
+FAIL: gcc.dg/fold-bitand-2.c scan-tree-dump-times original "return 2" 1
+FAIL: gcc.dg/fold-bitand-2.c scan-tree-dump-times original "return 3" 1
+FAIL: gcc.dg/fold-bitand-3.c scan-tree-dump-times original "& 3" 0
+FAIL: gcc.dg/fold-bitand-3.c scan-tree-dump-times original "return 1" 2
+FAIL: gcc.dg/pr52355.c (test for excess errors)
+FAIL: gcc.dg/tree-ssa/foldaddr-1.c scan-tree-dump-times original "return 0" 1
+FAIL: gcc.dg/tree-ssa/ivopt_4.c scan-tree-dump-times ivopts "ivtmp.[0-9_]* =
PHI <" 1
+FAIL: gcc.dg/tree-ssa/pr21985.c scan-tree-dump-times optimized "foo
\\\\([0-9]*\\\\)" 2
+FAIL: gcc.dg/tree-ssa/pr22051-2.c scan-tree-dump-times optimized "r_. =
\\\\(int\\\\) q" 1
+FAIL: gcc.target/i386/addr-space-5.c scan-assembler gs:
So, it even fails the new test I added there at the end.
Patch below, just in case I've misunderstood what you suggested.
r~
diff --git a/gcc/tree.c b/gcc/tree.c
index fa7646b..3e79c4b 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -12219,6 +12219,10 @@ block_ultimate_origin (const_tree block)
bool
tree_nop_conversion_p (const_tree outer_type, const_tree inner_type)
{
+ /* Do not strip conversions between pointers and integers. */
+ if (POINTER_TYPE_P (outer_type) != POINTER_TYPE_P (inner_type))
+ return false;
+
/* Use precision rather then machine mode when we can, which gives
the correct answer even for submode (bit-field) types. */
if ((INTEGRAL_TYPE_P (outer_type)
@@ -12272,8 +12276,7 @@ tree_sign_nop_conversion (const_tree exp)
outer_type = TREE_TYPE (exp);
inner_type = TREE_TYPE (TREE_OPERAND (exp, 0));
- return (TYPE_UNSIGNED (outer_type) == TYPE_UNSIGNED (inner_type)
- && POINTER_TYPE_P (outer_type) == POINTER_TYPE_P (inner_type));
+ return TYPE_UNSIGNED (outer_type) == TYPE_UNSIGNED (inner_type);
}
/* Strip conversions from EXP according to tree_nop_conversion and