--- /dev/null
+package Opt105_Pkg is
+
+ type Enum is (One, Two, Three);
+
+ Enabled : Boolean := False;
+ Disabled : Boolean := False;
+
+ function Cond1 return Boolean;
+ function Cond2 return Boolean;
+
+end Opt105_Pkg;
/* arg0_def_stmt should be conditional. */
if (dominated_by_p (CDI_DOMINATORS, gimple_bb (phi), gimple_bb (arg0_def_stmt)))
return NULL;
- /* If arg1 is an INTEGER_CST, fold it to new type. */
+
+ /* If arg1 is an INTEGER_CST, fold it to new type if it fits, or else
+ if the bits will not be modified during the conversion, except for
+ boolean types whose precision is not 1 (see int_fits_type_p). */
if (INTEGRAL_TYPE_P (TREE_TYPE (new_arg0))
&& (int_fits_type_p (arg1, TREE_TYPE (new_arg0))
|| (TYPE_PRECISION (TREE_TYPE (new_arg0))
- == TYPE_PRECISION (TREE_TYPE (arg1)))))
+ == TYPE_PRECISION (TREE_TYPE (arg1))
+ && (TREE_CODE (TREE_TYPE (new_arg0)) != BOOLEAN_TYPE
+ || TYPE_PRECISION (TREE_TYPE (new_arg0)) == 1))))
{
if (gimple_assign_cast_p (arg0_def_stmt))
{
it will not generate any zero/sign extend in that case. */
if ((TYPE_PRECISION (TREE_TYPE (new_arg0))
!= TYPE_PRECISION (TREE_TYPE (arg1)))
- && new_arg0 != gimple_cond_lhs (cond_stmt)
+ && new_arg0 != gimple_cond_lhs (cond_stmt)
&& new_arg0 != gimple_cond_rhs (cond_stmt)
&& gimple_bb (arg0_def_stmt) == e0->src)
{