This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix to pr47707
- From: Xinliang David Li <davidxl at google dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 11 Feb 2011 13:17:50 -0800
- Subject: Fix to pr47707
Hi,
the attached is the fix to the problem in scev. Bootstrapped in
linux/x86-64. Testing on going.
Ok for trunk after testing?
Thanks,
David
2011-02-11 Xinliang David Li <davidxl@google.com>
PR tree-optimization/47707
* tree-chrec.c (convert_affine_scev): Keep type precision.
2011-02-11 Xinliang David Li <davidxl@google.com>
PR tree-optimization/47707
* g++.dg/tree-ssa/pr47707.C: New test.
Index: tree-chrec.c
===================================================================
--- tree-chrec.c (revision 170058)
+++ tree-chrec.c (working copy)
@@ -1238,8 +1238,13 @@ convert_affine_scev (struct loop *loop,
performed by default when CT is signed. */
new_step = *step;
if (TYPE_PRECISION (step_type) > TYPE_PRECISION (ct) && TYPE_UNSIGNED (ct))
- new_step = chrec_convert_1 (signed_type_for (ct), new_step, at_stmt,
- use_overflow_semantics);
+ {
+ tree signed_ct = signed_type_for (ct);
+ if (TYPE_PRECISION (signed_ct) != TYPE_PRECISION (ct))
+ signed_ct = build_nonstandard_integer_type (TYPE_PRECISION (ct), 0);
+ new_step = chrec_convert_1 (signed_ct, new_step, at_stmt,
+ use_overflow_semantics);
+ }
new_step = chrec_convert_1 (step_type, new_step, at_stmt, use_overflow_semantics);
if (automatically_generated_chrec_p (new_base)
@@ -1579,4 +1584,3 @@ evolution_function_right_is_integer_cst
return false;
}
}
-
Index: testsuite/g++.dg/tree-ssa/pr47707.C
===================================================================
--- testsuite/g++.dg/tree-ssa/pr47707.C (revision 0)
+++ testsuite/g++.dg/tree-ssa/pr47707.C (revision 0)
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-tree-vrp" } */
+#include <assert.h>
+
+struct CH
+{
+ unsigned char ch : 3;
+} ch;
+
+__attribute__((noinline)) void MakeCheckOp (unsigned int *v1, unsigned int *v2)
+{
+ assert (*v1 == *v2);
+
+}
+
+int main (void)
+{
+
+ int len;
+
+ for (len = 4; len >= 1; len--)
+ {
+ unsigned v1, v2;
+ ch.ch = len;
+ v1 = ch.ch;
+ v2 = len;
+ MakeCheckOp (&v1, &v2);
+ }
+}