This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR38405
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 7 Dec 2008 21:31:56 +0100 (CET)
- Subject: [PATCH] Fix PR38405
This fixes the now latent PR38405. We should not replace
a comparison against zero with a sign-extension for 1-bit
integer types.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2008-12-07 Richard Guenther <rguenther@suse.de>
PR tree-optimization/38405
* tree-vrp.c (simplify_truth_ops_using_ranges): Make sure to
not sign-extend truth values.
Index: gcc/tree-vrp.c
===================================================================
*** gcc/tree-vrp.c (revision 142538)
--- gcc/tree-vrp.c (working copy)
*************** simplify_truth_ops_using_ranges (gimple_
*** 6512,6517 ****
--- 6512,6523 ----
!useless_type_conversion_p (TREE_TYPE (gimple_assign_lhs (stmt)),
TREE_TYPE (op0));
+ /* Make sure to not sign-extend -1 as a boolean value. */
+ if (need_conversion
+ && !TYPE_UNSIGNED (TREE_TYPE (op0))
+ && TYPE_PRECISION (TREE_TYPE (op0)) == 1)
+ return false;
+
switch (rhs_code)
{
case TRUTH_AND_EXPR: