diff mbox series

introduce predicate analysis class

Message ID d82b0c20-24ed-1f84-8c28-492720c726a1@gmail.com
State New
Headers show
Series introduce predicate analysis class | expand

Commit Message

Martin Sebor Aug. 30, 2021, 8:03 p.m. UTC
The predicate analysis subset of the tree-ssa-uninit pass isn't
necessarily specific to the detection of uninitialized reads.
Suitably parameterized, the same core logic could be used in
other warning passes to improve their S/N ratio, or issue more
nuanced diagnostics (e.g., when an invalid access cannot be
ruled out but also need not in reality be unavoidable, issue
a "may be invalid" type of warning rather than "is invalid").

Separating the predicate analysis logic from the uninitialized
pass and exposing a narrow API should also make it easier to
understand and evolve each part independently of the other,
or replace one with a better implementation without modifying
the other.(*)

As the first step in this direction, the attached patch extracts
the predicate analysis logic out of the pass, turns the interface
into public class members, and hides the internals in either
private members or static functions defined in a new source file.
(**)

The changes should have no externally observable effect (i.e.,
should cause no changes in warnings), except on the contents of
the uninitialized dump.  While making the changes I enhanced
the dumps to help me follow the logic.  Turning some previously
free-standing functions into members involved changing their
signatures and adjusting their callers.  While making these
changes I also renamed some of them as well some variables for
improved clarity.  Finally, I moved declarations of locals
closer to their point of initialization.

Tested on x86_64-linux.  Besides the usual bootstrap/regtest
I also tentatively verified the generality of the new class
interfaces by making use of it in -Warray-bounds.  Besides there,
I'd like to make use of it in the new gimple-ssa-warn-access pass
and, longer term, any other flow-sensitive warnings that might
benefit from it.

Martin

[*] A review of open -Wuninitialized bugs I did while working
on this project made me aware of a number of opportunities to
improve the analyzer to reduce the number of false positives
-Wmaybe-uninitiailzed suffers from.

[**] The class isn't fully general and, like the uninit pass,
only works with PHI nodes.  I plan to generalize it to compute
the set of predicates between any two basic blocks.

Comments

Jeff Law Sept. 2, 2021, 4:28 p.m. UTC | #1
On 8/30/2021 2:03 PM, Martin Sebor via Gcc-patches wrote:
> The predicate analysis subset of the tree-ssa-uninit pass isn't
> necessarily specific to the detection of uninitialized reads.
> Suitably parameterized, the same core logic could be used in
> other warning passes to improve their S/N ratio, or issue more
> nuanced diagnostics (e.g., when an invalid access cannot be
> ruled out but also need not in reality be unavoidable, issue
> a "may be invalid" type of warning rather than "is invalid").
>
> Separating the predicate analysis logic from the uninitialized
> pass and exposing a narrow API should also make it easier to
> understand and evolve each part independently of the other,
> or replace one with a better implementation without modifying
> the other.(*)
>
> As the first step in this direction, the attached patch extracts
> the predicate analysis logic out of the pass, turns the interface
> into public class members, and hides the internals in either
> private members or static functions defined in a new source file.
> (**)
>
> The changes should have no externally observable effect (i.e.,
> should cause no changes in warnings), except on the contents of
> the uninitialized dump.  While making the changes I enhanced
> the dumps to help me follow the logic.  Turning some previously
> free-standing functions into members involved changing their
> signatures and adjusting their callers.  While making these
> changes I also renamed some of them as well some variables for
> improved clarity.  Finally, I moved declarations of locals
> closer to their point of initialization.
>
> Tested on x86_64-linux.  Besides the usual bootstrap/regtest
> I also tentatively verified the generality of the new class
> interfaces by making use of it in -Warray-bounds.  Besides there,
> I'd like to make use of it in the new gimple-ssa-warn-access pass
> and, longer term, any other flow-sensitive warnings that might
> benefit from it.
>
> Martin
>
> [*] A review of open -Wuninitialized bugs I did while working
> on this project made me aware of a number of opportunities to
> improve the analyzer to reduce the number of false positives
> -Wmaybe-uninitiailzed suffers from.
>
> [**] The class isn't fully general and, like the uninit pass,
> only works with PHI nodes.  I plan to generalize it to compute
> the set of predicates between any two basic blocks.
>
> gcc-predanal.diff
>
> Factor predidacte analysis out of tree-ssa-uninit.c into its own module.
>
> gcc/ChangeLog:
>
> 	* Makefile.in (OBJS): Add gimple-predicate-analysis.o.
> 	* tree-ssa-uninit.c (max_phi_args): Move to gimple-predicate-analysis.
> 	(MASK_SET_BIT, MASK_TEST_BIT, MASK_EMPTY): Same.
> 	(check_defs):
> 	(can_skip_redundant_opnd):
> 	(compute_uninit_opnds_pos): Adjust to namespace change.
> 	(find_pdom): Move to gimple-predicate-analysis.cc.
> 	(find_dom): Same.
> 	(struct uninit_undef_val_t): New.
> 	(is_non_loop_exit_postdominating): Move to gimple-predicate-analysis.cc.
> 	(find_control_equiv_block): Same.
> 	(MAX_NUM_CHAINS, MAX_CHAIN_LEN, MAX_POSTDOM_CHECK): Same.
> 	(MAX_SWITCH_CASES): Same.
> 	(compute_control_dep_chain): Same.
> 	(find_uninit_use): Use predicate analyzer.
> 	(struct pred_info): Move to gimple-predicate-analysis.
> 	(convert_control_dep_chain_into_preds): Same.
> 	(find_predicates): Same.
> 	(collect_phi_def_edges): Same.
> 	(warn_uninitialized_phi): Use predicate analyzer.
> 	(find_def_preds): Move to gimple-predicate-analysis.
> 	(dump_pred_info): Same.
> 	(dump_pred_chain): Same.
> 	(dump_predicates): Same.
> 	(destroy_predicate_vecs): Remove.
> 	(execute_late_warn_uninitialized): New.
> 	(get_cmp_code): Move to gimple-predicate-analysis.
> 	(is_value_included_in): Same.
> 	(value_sat_pred_p): Same.
> 	(find_matching_predicate_in_rest_chains): Same.
> 	(is_use_properly_guarded): Same.
> 	(prune_uninit_phi_opnds): Same.
> 	(find_var_cmp_const): Same.
> 	(use_pred_not_overlap_with_undef_path_pred): Same.
> 	(pred_equal_p): Same.
> 	(is_neq_relop_p): Same.
> 	(is_neq_zero_form_p): Same.
> 	(pred_expr_equal_p): Same.
> 	(is_pred_expr_subset_of): Same.
> 	(is_pred_chain_subset_of): Same.
> 	(is_included_in): Same.
> 	(is_superset_of): Same.
> 	(pred_neg_p): Same.
> 	(simplify_pred): Same.
> 	(simplify_preds_2): Same.
> 	(simplify_preds_3): Same.
> 	(simplify_preds_4): Same.
> 	(simplify_preds): Same.
> 	(push_pred): Same.
> 	(push_to_worklist): Same.
> 	(get_pred_info_from_cmp): Same.
> 	(is_degenerated_phi): Same.
> 	(normalize_one_pred_1): Same.
> 	(normalize_one_pred): Same.
> 	(normalize_one_pred_chain): Same.
> 	(normalize_preds): Same.
> 	(can_one_predicate_be_invalidated_p): Same.
> 	(can_chain_union_be_invalidated_p): Same.
> 	(uninit_uses_cannot_happen): Same.
> 	(pass_late_warn_uninitialized::execute): Define.
> 	* gimple-predicate-analysis.cc: New file.
> 	* gimple-predicate-analysis.h: New file.
Thanks for tackling this.  It's something I think we've needed for a 
long time.

I've only done a cursory review since this is primarily moving the 
analysis engine to its own file and class-ifying it.

As we build additional consumers I won't be surprised if we have to 
adjust the exposed class API, but that's fine.   The first goal is to 
get the analysis disentangled from the consumer(s).

OK.  Looking forward to seeing the analysis used elsewhere.

Jeff
Martin Sebor Sept. 17, 2021, 10:05 p.m. UTC | #2
On 9/2/21 10:28 AM, Jeff Law via Gcc-patches wrote:
> 
> 
> On 8/30/2021 2:03 PM, Martin Sebor via Gcc-patches wrote:
>> The predicate analysis subset of the tree-ssa-uninit pass isn't
>> necessarily specific to the detection of uninitialized reads.
>> Suitably parameterized, the same core logic could be used in
>> other warning passes to improve their S/N ratio, or issue more
>> nuanced diagnostics (e.g., when an invalid access cannot be
>> ruled out but also need not in reality be unavoidable, issue
>> a "may be invalid" type of warning rather than "is invalid").
>>
>> Separating the predicate analysis logic from the uninitialized
>> pass and exposing a narrow API should also make it easier to
>> understand and evolve each part independently of the other,
>> or replace one with a better implementation without modifying
>> the other.(*)
>>
>> As the first step in this direction, the attached patch extracts
>> the predicate analysis logic out of the pass, turns the interface
>> into public class members, and hides the internals in either
>> private members or static functions defined in a new source file.
>> (**)
>>
>> The changes should have no externally observable effect (i.e.,
>> should cause no changes in warnings), except on the contents of
>> the uninitialized dump.  While making the changes I enhanced
>> the dumps to help me follow the logic.  Turning some previously
>> free-standing functions into members involved changing their
>> signatures and adjusting their callers.  While making these
>> changes I also renamed some of them as well some variables for
>> improved clarity.  Finally, I moved declarations of locals
>> closer to their point of initialization.
>>
>> Tested on x86_64-linux.  Besides the usual bootstrap/regtest
>> I also tentatively verified the generality of the new class
>> interfaces by making use of it in -Warray-bounds.  Besides there,
>> I'd like to make use of it in the new gimple-ssa-warn-access pass
>> and, longer term, any other flow-sensitive warnings that might
>> benefit from it.
>>
>> Martin
>>
>> [*] A review of open -Wuninitialized bugs I did while working
>> on this project made me aware of a number of opportunities to
>> improve the analyzer to reduce the number of false positives
>> -Wmaybe-uninitiailzed suffers from.
>>
>> [**] The class isn't fully general and, like the uninit pass,
>> only works with PHI nodes.  I plan to generalize it to compute
>> the set of predicates between any two basic blocks.
>>
>> gcc-predanal.diff
>>
>> Factor predidacte analysis out of tree-ssa-uninit.c into its own module.
>>
>> gcc/ChangeLog:
>>
>>     * Makefile.in (OBJS): Add gimple-predicate-analysis.o.
>>     * tree-ssa-uninit.c (max_phi_args): Move to 
>> gimple-predicate-analysis.
>>     (MASK_SET_BIT, MASK_TEST_BIT, MASK_EMPTY): Same.
>>     (check_defs):
>>     (can_skip_redundant_opnd):
>>     (compute_uninit_opnds_pos): Adjust to namespace change.
>>     (find_pdom): Move to gimple-predicate-analysis.cc.
>>     (find_dom): Same.
>>     (struct uninit_undef_val_t): New.
>>     (is_non_loop_exit_postdominating): Move to 
>> gimple-predicate-analysis.cc.
>>     (find_control_equiv_block): Same.
>>     (MAX_NUM_CHAINS, MAX_CHAIN_LEN, MAX_POSTDOM_CHECK): Same.
>>     (MAX_SWITCH_CASES): Same.
>>     (compute_control_dep_chain): Same.
>>     (find_uninit_use): Use predicate analyzer.
>>     (struct pred_info): Move to gimple-predicate-analysis.
>>     (convert_control_dep_chain_into_preds): Same.
>>     (find_predicates): Same.
>>     (collect_phi_def_edges): Same.
>>     (warn_uninitialized_phi): Use predicate analyzer.
>>     (find_def_preds): Move to gimple-predicate-analysis.
>>     (dump_pred_info): Same.
>>     (dump_pred_chain): Same.
>>     (dump_predicates): Same.
>>     (destroy_predicate_vecs): Remove.
>>     (execute_late_warn_uninitialized): New.
>>     (get_cmp_code): Move to gimple-predicate-analysis.
>>     (is_value_included_in): Same.
>>     (value_sat_pred_p): Same.
>>     (find_matching_predicate_in_rest_chains): Same.
>>     (is_use_properly_guarded): Same.
>>     (prune_uninit_phi_opnds): Same.
>>     (find_var_cmp_const): Same.
>>     (use_pred_not_overlap_with_undef_path_pred): Same.
>>     (pred_equal_p): Same.
>>     (is_neq_relop_p): Same.
>>     (is_neq_zero_form_p): Same.
>>     (pred_expr_equal_p): Same.
>>     (is_pred_expr_subset_of): Same.
>>     (is_pred_chain_subset_of): Same.
>>     (is_included_in): Same.
>>     (is_superset_of): Same.
>>     (pred_neg_p): Same.
>>     (simplify_pred): Same.
>>     (simplify_preds_2): Same.
>>     (simplify_preds_3): Same.
>>     (simplify_preds_4): Same.
>>     (simplify_preds): Same.
>>     (push_pred): Same.
>>     (push_to_worklist): Same.
>>     (get_pred_info_from_cmp): Same.
>>     (is_degenerated_phi): Same.
>>     (normalize_one_pred_1): Same.
>>     (normalize_one_pred): Same.
>>     (normalize_one_pred_chain): Same.
>>     (normalize_preds): Same.
>>     (can_one_predicate_be_invalidated_p): Same.
>>     (can_chain_union_be_invalidated_p): Same.
>>     (uninit_uses_cannot_happen): Same.
>>     (pass_late_warn_uninitialized::execute): Define.
>>     * gimple-predicate-analysis.cc: New file.
>>     * gimple-predicate-analysis.h: New file.
> Thanks for tackling this.  It's something I think we've needed for a 
> long time.
> 
> I've only done a cursory review since this is primarily moving the 
> analysis engine to its own file and class-ifying it.
> 
> As we build additional consumers I won't be surprised if we have to 
> adjust the exposed class API, but that's fine.   The first goal is to 
> get the analysis disentangled from the consumer(s).
> 
> OK.  Looking forward to seeing the analysis used elsewhere.

Thanks, I just pushed it.

As a heads up, I've been having some weird email problems lately and
didn't find your approval until today, in my Trash folder.  Just in
case there's fallout that I'm not responsive to, please either ping
me on IRC or email my @redhat account.

Martin
Jeff Law Sept. 18, 2021, 4:08 a.m. UTC | #3
On 9/17/2021 4:05 PM, Martin Sebor wrote:
> On 9/2/21 10:28 AM, Jeff Law via Gcc-patches wrote:
>>
>>
>> On 8/30/2021 2:03 PM, Martin Sebor via Gcc-patches wrote:
>>> The predicate analysis subset of the tree-ssa-uninit pass isn't
>>> necessarily specific to the detection of uninitialized reads.
>>> Suitably parameterized, the same core logic could be used in
>>> other warning passes to improve their S/N ratio, or issue more
>>> nuanced diagnostics (e.g., when an invalid access cannot be
>>> ruled out but also need not in reality be unavoidable, issue
>>> a "may be invalid" type of warning rather than "is invalid").
>>>
>>> Separating the predicate analysis logic from the uninitialized
>>> pass and exposing a narrow API should also make it easier to
>>> understand and evolve each part independently of the other,
>>> or replace one with a better implementation without modifying
>>> the other.(*)
>>>
>>> As the first step in this direction, the attached patch extracts
>>> the predicate analysis logic out of the pass, turns the interface
>>> into public class members, and hides the internals in either
>>> private members or static functions defined in a new source file.
>>> (**)
>>>
>>> The changes should have no externally observable effect (i.e.,
>>> should cause no changes in warnings), except on the contents of
>>> the uninitialized dump.  While making the changes I enhanced
>>> the dumps to help me follow the logic.  Turning some previously
>>> free-standing functions into members involved changing their
>>> signatures and adjusting their callers.  While making these
>>> changes I also renamed some of them as well some variables for
>>> improved clarity.  Finally, I moved declarations of locals
>>> closer to their point of initialization.
>>>
>>> Tested on x86_64-linux.  Besides the usual bootstrap/regtest
>>> I also tentatively verified the generality of the new class
>>> interfaces by making use of it in -Warray-bounds.  Besides there,
>>> I'd like to make use of it in the new gimple-ssa-warn-access pass
>>> and, longer term, any other flow-sensitive warnings that might
>>> benefit from it.
>>>
>>> Martin
>>>
>>> [*] A review of open -Wuninitialized bugs I did while working
>>> on this project made me aware of a number of opportunities to
>>> improve the analyzer to reduce the number of false positives
>>> -Wmaybe-uninitiailzed suffers from.
>>>
>>> [**] The class isn't fully general and, like the uninit pass,
>>> only works with PHI nodes.  I plan to generalize it to compute
>>> the set of predicates between any two basic blocks.
>>>
>>> gcc-predanal.diff
>>>
>>> Factor predidacte analysis out of tree-ssa-uninit.c into its own 
>>> module.
>>>
>>> gcc/ChangeLog:
>>>
>>>     * Makefile.in (OBJS): Add gimple-predicate-analysis.o.
>>>     * tree-ssa-uninit.c (max_phi_args): Move to 
>>> gimple-predicate-analysis.
>>>     (MASK_SET_BIT, MASK_TEST_BIT, MASK_EMPTY): Same.
>>>     (check_defs):
>>>     (can_skip_redundant_opnd):
>>>     (compute_uninit_opnds_pos): Adjust to namespace change.
>>>     (find_pdom): Move to gimple-predicate-analysis.cc.
>>>     (find_dom): Same.
>>>     (struct uninit_undef_val_t): New.
>>>     (is_non_loop_exit_postdominating): Move to 
>>> gimple-predicate-analysis.cc.
>>>     (find_control_equiv_block): Same.
>>>     (MAX_NUM_CHAINS, MAX_CHAIN_LEN, MAX_POSTDOM_CHECK): Same.
>>>     (MAX_SWITCH_CASES): Same.
>>>     (compute_control_dep_chain): Same.
>>>     (find_uninit_use): Use predicate analyzer.
>>>     (struct pred_info): Move to gimple-predicate-analysis.
>>>     (convert_control_dep_chain_into_preds): Same.
>>>     (find_predicates): Same.
>>>     (collect_phi_def_edges): Same.
>>>     (warn_uninitialized_phi): Use predicate analyzer.
>>>     (find_def_preds): Move to gimple-predicate-analysis.
>>>     (dump_pred_info): Same.
>>>     (dump_pred_chain): Same.
>>>     (dump_predicates): Same.
>>>     (destroy_predicate_vecs): Remove.
>>>     (execute_late_warn_uninitialized): New.
>>>     (get_cmp_code): Move to gimple-predicate-analysis.
>>>     (is_value_included_in): Same.
>>>     (value_sat_pred_p): Same.
>>>     (find_matching_predicate_in_rest_chains): Same.
>>>     (is_use_properly_guarded): Same.
>>>     (prune_uninit_phi_opnds): Same.
>>>     (find_var_cmp_const): Same.
>>>     (use_pred_not_overlap_with_undef_path_pred): Same.
>>>     (pred_equal_p): Same.
>>>     (is_neq_relop_p): Same.
>>>     (is_neq_zero_form_p): Same.
>>>     (pred_expr_equal_p): Same.
>>>     (is_pred_expr_subset_of): Same.
>>>     (is_pred_chain_subset_of): Same.
>>>     (is_included_in): Same.
>>>     (is_superset_of): Same.
>>>     (pred_neg_p): Same.
>>>     (simplify_pred): Same.
>>>     (simplify_preds_2): Same.
>>>     (simplify_preds_3): Same.
>>>     (simplify_preds_4): Same.
>>>     (simplify_preds): Same.
>>>     (push_pred): Same.
>>>     (push_to_worklist): Same.
>>>     (get_pred_info_from_cmp): Same.
>>>     (is_degenerated_phi): Same.
>>>     (normalize_one_pred_1): Same.
>>>     (normalize_one_pred): Same.
>>>     (normalize_one_pred_chain): Same.
>>>     (normalize_preds): Same.
>>>     (can_one_predicate_be_invalidated_p): Same.
>>>     (can_chain_union_be_invalidated_p): Same.
>>>     (uninit_uses_cannot_happen): Same.
>>>     (pass_late_warn_uninitialized::execute): Define.
>>>     * gimple-predicate-analysis.cc: New file.
>>>     * gimple-predicate-analysis.h: New file.
>> Thanks for tackling this.  It's something I think we've needed for a 
>> long time.
>>
>> I've only done a cursory review since this is primarily moving the 
>> analysis engine to its own file and class-ifying it.
>>
>> As we build additional consumers I won't be surprised if we have to 
>> adjust the exposed class API, but that's fine.   The first goal is to 
>> get the analysis disentangled from the consumer(s).
>>
>> OK.  Looking forward to seeing the analysis used elsewhere.
>
> Thanks, I just pushed it.
>
> As a heads up, I've been having some weird email problems lately and
> didn't find your approval until today, in my Trash folder.  Just in
> case there's fallout that I'm not responsive to, please either ping
> me on IRC or email my @redhat account.
Weird.  I wonder if google is trying to tell me something :-)

Anyway,  it does seem to be triggering an ICE on nios2-linux-gnu and 
csky-linux-gnu (so far).

Compile the attached code with -O2 -Wall  with a nios2-linux-gnu cross 
compiler.  You should get an ICE in the predicate bits.

Jeff
# 0 "../sysdeps/ieee754/soft-fp/s_fmaf.c"
# 1 "/home/jlaw/jenkins/workspace/nios2-linux-gnu/glibc/math//"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "../include/stdc-predef.h" 1
# 0 "<command-line>" 2
# 1 "/home/jlaw/jenkins/workspace/nios2-linux-gnu/nios2-linux-gnu-obj/glibc/libc-modules.h" 1
# 0 "<command-line>" 2
# 1 "./../include/libc-symbols.h" 1
# 85 "./../include/libc-symbols.h"
# 1 "/home/jlaw/jenkins/workspace/nios2-linux-gnu/nios2-linux-gnu-obj/glibc/config.h" 1
# 86 "./../include/libc-symbols.h" 2


# 1 "../sysdeps/generic/libc-symver.h" 1
# 25 "../sysdeps/generic/libc-symver.h"
# 1 "/home/jlaw/jenkins/workspace/nios2-linux-gnu/nios2-linux-gnu-obj/glibc/config.h" 1
# 26 "../sysdeps/generic/libc-symver.h" 2
# 89 "./../include/libc-symbols.h" 2
# 865 "./../include/libc-symbols.h"
# 1 "../sysdeps/generic/symbol-hacks.h" 1
# 866 "./../include/libc-symbols.h" 2
# 0 "<command-line>" 2
# 1 "../sysdeps/ieee754/soft-fp/s_fmaf.c"
# 29 "../sysdeps/ieee754/soft-fp/s_fmaf.c"
# 1 "../include/math.h" 1






# 1 "../math/math.h" 1
# 27 "../math/math.h"
# 1 "../bits/libc-header-start.h" 1
# 33 "../bits/libc-header-start.h"
# 1 "../include/features.h" 1
# 392 "../include/features.h"
# 1 "../include/features-time64.h" 1
# 1 "../sysdeps/unix/sysv/linux/features-time64.h" 1
# 20 "../sysdeps/unix/sysv/linux/features-time64.h"
# 1 "../sysdeps/wordsize-32/bits/wordsize.h" 1
# 21 "../sysdeps/unix/sysv/linux/features-time64.h" 2
# 1 "../bits/timesize.h" 1
# 19 "../bits/timesize.h"
# 1 "../sysdeps/wordsize-32/bits/wordsize.h" 1
# 20 "../bits/timesize.h" 2
# 22 "../sysdeps/unix/sysv/linux/features-time64.h" 2
# 2 "../include/features-time64.h" 2
# 393 "../include/features.h" 2
# 488 "../include/features.h"
# 1 "../include/sys/cdefs.h" 1
# 10 "../include/sys/cdefs.h"
# 1 "../misc/sys/cdefs.h" 1
# 499 "../misc/sys/cdefs.h"
# 1 "../sysdeps/wordsize-32/bits/wordsize.h" 1
# 500 "../misc/sys/cdefs.h" 2
# 1 "../bits/long-double.h" 1
# 501 "../misc/sys/cdefs.h" 2
# 11 "../include/sys/cdefs.h" 2
# 19 "../include/sys/cdefs.h"
extern void __chk_fail (void) __attribute__ ((__noreturn__));


# 489 "../include/features.h" 2
# 512 "../include/features.h"
# 1 "../include/gnu/stubs.h" 1
# 513 "../include/features.h" 2
# 34 "../bits/libc-header-start.h" 2
# 28 "../math/math.h" 2









# 1 "../include/bits/types.h" 1
# 1 "../posix/bits/types.h" 1
# 27 "../posix/bits/types.h"
# 1 "../sysdeps/wordsize-32/bits/wordsize.h" 1
# 28 "../posix/bits/types.h" 2
# 1 "../bits/timesize.h" 1
# 19 "../bits/timesize.h"
# 1 "../sysdeps/wordsize-32/bits/wordsize.h" 1
# 20 "../bits/timesize.h" 2
# 29 "../posix/bits/types.h" 2


typedef unsigned char __u_char;
typedef unsigned short int __u_short;
typedef unsigned int __u_int;
typedef unsigned long int __u_long;


typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef signed short int __int16_t;
typedef unsigned short int __uint16_t;
typedef signed int __int32_t;
typedef unsigned int __uint32_t;




__extension__ typedef signed long long int __int64_t;
__extension__ typedef unsigned long long int __uint64_t;



typedef __int8_t __int_least8_t;
typedef __uint8_t __uint_least8_t;
typedef __int16_t __int_least16_t;
typedef __uint16_t __uint_least16_t;
typedef __int32_t __int_least32_t;
typedef __uint32_t __uint_least32_t;
typedef __int64_t __int_least64_t;
typedef __uint64_t __uint_least64_t;






__extension__ typedef long long int __quad_t;
__extension__ typedef unsigned long long int __u_quad_t;







__extension__ typedef long long int __intmax_t;
__extension__ typedef unsigned long long int __uintmax_t;
# 141 "../posix/bits/types.h"
# 1 "../sysdeps/unix/sysv/linux/generic/bits/typesizes.h" 1
# 142 "../posix/bits/types.h" 2
# 1 "../bits/time64.h" 1
# 143 "../posix/bits/types.h" 2


__extension__ typedef __uint64_t __dev_t;
__extension__ typedef unsigned int __uid_t;
__extension__ typedef unsigned int __gid_t;
__extension__ typedef unsigned long int __ino_t;
__extension__ typedef __uint64_t __ino64_t;
__extension__ typedef unsigned int __mode_t;
__extension__ typedef unsigned int __nlink_t;
__extension__ typedef long int __off_t;
__extension__ typedef __int64_t __off64_t;
__extension__ typedef int __pid_t;
__extension__ typedef struct { int __val[2]; } __fsid_t;
__extension__ typedef long int __clock_t;
__extension__ typedef unsigned long int __rlim_t;
__extension__ typedef __uint64_t __rlim64_t;
__extension__ typedef unsigned int __id_t;
__extension__ typedef long int __time_t;
__extension__ typedef unsigned int __useconds_t;
__extension__ typedef long int __suseconds_t;
__extension__ typedef __int64_t __suseconds64_t;

__extension__ typedef int __daddr_t;
__extension__ typedef int __key_t;


__extension__ typedef int __clockid_t;


__extension__ typedef void * __timer_t;


__extension__ typedef int __blksize_t;




__extension__ typedef long int __blkcnt_t;
__extension__ typedef __int64_t __blkcnt64_t;


__extension__ typedef unsigned long int __fsblkcnt_t;
__extension__ typedef __uint64_t __fsblkcnt64_t;


__extension__ typedef unsigned long int __fsfilcnt_t;
__extension__ typedef __uint64_t __fsfilcnt64_t;


__extension__ typedef int __fsword_t;

__extension__ typedef int __ssize_t;


__extension__ typedef long int __syscall_slong_t;

__extension__ typedef unsigned long int __syscall_ulong_t;



typedef __off64_t __loff_t;
typedef char *__caddr_t;


__extension__ typedef int __intptr_t;


__extension__ typedef unsigned int __socklen_t;




typedef int __sig_atomic_t;







__extension__ typedef __int64_t __time64_t;
# 2 "../include/bits/types.h" 2
# 38 "../math/math.h" 2


# 1 "../bits/math-vector.h" 1
# 27 "../bits/math-vector.h"
# 1 "../bits/libm-simd-decl-stubs.h" 1
# 28 "../bits/math-vector.h" 2
# 41 "../math/math.h" 2


# 1 "../bits/floatn.h" 1
# 52 "../bits/floatn.h"
# 1 "../bits/floatn-common.h" 1
# 24 "../bits/floatn-common.h"
# 1 "../bits/long-double.h" 1
# 25 "../bits/floatn-common.h" 2
# 53 "../bits/floatn.h" 2
# 44 "../math/math.h" 2
# 152 "../math/math.h"
# 1 "../bits/flt-eval-method.h" 1
# 153 "../math/math.h" 2
# 163 "../math/math.h"
typedef float float_t;
typedef double double_t;
# 204 "../math/math.h"
# 1 "../bits/fp-logb.h" 1
# 205 "../math/math.h" 2
# 247 "../math/math.h"
# 1 "../bits/fp-fast.h" 1
# 248 "../math/math.h" 2



enum
  {
    FP_INT_UPWARD =

      0,
    FP_INT_DOWNWARD =

      1,
    FP_INT_TOWARDZERO =

      2,
    FP_INT_TONEARESTFROMZERO =

      3,
    FP_INT_TONEAREST =

      4,
  };
# 312 "../math/math.h"
# 1 "../include/bits/mathcalls-helper-functions.h" 1
# 1 "../math/bits/mathcalls-helper-functions.h" 1
# 20 "../math/bits/mathcalls-helper-functions.h"
extern int __fpclassify (double __value) __attribute__ ((__nothrow__ ))
     __attribute__ ((__const__));


extern int __signbit (double __value) __attribute__ ((__nothrow__ ))
     __attribute__ ((__const__));



extern int __isinf (double __value) __attribute__ ((__nothrow__ ))
  __attribute__ ((__const__));


extern int __finite (double __value) __attribute__ ((__nothrow__ ))
  __attribute__ ((__const__));


extern int __isnan (double __value) __attribute__ ((__nothrow__ ))
  __attribute__ ((__const__));


extern int __iseqsig (double __x, double __y) __attribute__ ((__nothrow__ ));


extern int __issignaling (double __value) __attribute__ ((__nothrow__ ))
     __attribute__ ((__const__));
# 2 "../include/bits/mathcalls-helper-functions.h" 2
# 313 "../math/math.h" 2
# 1 "../include/bits/mathcalls.h" 1
# 1 "../math/bits/mathcalls.h" 1
# 53 "../math/bits/mathcalls.h"
extern double acos (double __x) __attribute__ ((__nothrow__ )); extern double __acos (double __x) __attribute__ ((__nothrow__ ));

extern double asin (double __x) __attribute__ ((__nothrow__ )); extern double __asin (double __x) __attribute__ ((__nothrow__ ));

extern double atan (double __x) __attribute__ ((__nothrow__ )); extern double __atan (double __x) __attribute__ ((__nothrow__ ));

extern double atan2 (double __y, double __x) __attribute__ ((__nothrow__ )); extern double __atan2 (double __y, double __x) __attribute__ ((__nothrow__ ));


 extern double cos (double __x) __attribute__ ((__nothrow__ )); extern double __cos (double __x) __attribute__ ((__nothrow__ ));

 extern double sin (double __x) __attribute__ ((__nothrow__ )); extern double __sin (double __x) __attribute__ ((__nothrow__ ));

extern double tan (double __x) __attribute__ ((__nothrow__ )); extern double __tan (double __x) __attribute__ ((__nothrow__ ));




extern double cosh (double __x) __attribute__ ((__nothrow__ )); extern double __cosh (double __x) __attribute__ ((__nothrow__ ));

extern double sinh (double __x) __attribute__ ((__nothrow__ )); extern double __sinh (double __x) __attribute__ ((__nothrow__ ));

extern double tanh (double __x) __attribute__ ((__nothrow__ )); extern double __tanh (double __x) __attribute__ ((__nothrow__ ));



 extern void sincos (double __x, double *__sinx, double *__cosx) __attribute__ ((__nothrow__ )); extern void __sincos (double __x, double *__sinx, double *__cosx) __attribute__ ((__nothrow__ ))
                                                        ;




extern double acosh (double __x) __attribute__ ((__nothrow__ )); extern double __acosh (double __x) __attribute__ ((__nothrow__ ));

extern double asinh (double __x) __attribute__ ((__nothrow__ )); extern double __asinh (double __x) __attribute__ ((__nothrow__ ));

extern double atanh (double __x) __attribute__ ((__nothrow__ )); extern double __atanh (double __x) __attribute__ ((__nothrow__ ));





 extern double exp (double __x) __attribute__ ((__nothrow__ )); extern double __exp (double __x) __attribute__ ((__nothrow__ ));


extern double frexp (double __x, int *__exponent) __attribute__ ((__nothrow__ )); extern double __frexp (double __x, int *__exponent) __attribute__ ((__nothrow__ ));


extern double ldexp (double __x, int __exponent) __attribute__ ((__nothrow__ )); extern double __ldexp (double __x, int __exponent) __attribute__ ((__nothrow__ ));


 extern double log (double __x) __attribute__ ((__nothrow__ )); extern double __log (double __x) __attribute__ ((__nothrow__ ));


extern double log10 (double __x) __attribute__ ((__nothrow__ )); extern double __log10 (double __x) __attribute__ ((__nothrow__ ));


extern double modf (double __x, double *__iptr) __attribute__ ((__nothrow__ )); extern double __modf (double __x, double *__iptr) __attribute__ ((__nothrow__ )) ;



extern double exp10 (double __x) __attribute__ ((__nothrow__ )); extern double __exp10 (double __x) __attribute__ ((__nothrow__ ));




extern double expm1 (double __x) __attribute__ ((__nothrow__ )); extern double __expm1 (double __x) __attribute__ ((__nothrow__ ));


extern double log1p (double __x) __attribute__ ((__nothrow__ )); extern double __log1p (double __x) __attribute__ ((__nothrow__ ));


extern double logb (double __x) __attribute__ ((__nothrow__ )); extern double __logb (double __x) __attribute__ ((__nothrow__ ));




extern double exp2 (double __x) __attribute__ ((__nothrow__ )); extern double __exp2 (double __x) __attribute__ ((__nothrow__ ));


extern double log2 (double __x) __attribute__ ((__nothrow__ )); extern double __log2 (double __x) __attribute__ ((__nothrow__ ));






 extern double pow (double __x, double __y) __attribute__ ((__nothrow__ )); extern double __pow (double __x, double __y) __attribute__ ((__nothrow__ ));


extern double sqrt (double __x) __attribute__ ((__nothrow__ )); extern double __sqrt (double __x) __attribute__ ((__nothrow__ ));



extern double hypot (double __x, double __y) __attribute__ ((__nothrow__ )); extern double __hypot (double __x, double __y) __attribute__ ((__nothrow__ ));




extern double cbrt (double __x) __attribute__ ((__nothrow__ )); extern double __cbrt (double __x) __attribute__ ((__nothrow__ ));






extern double ceil (double __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern double __ceil (double __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));


extern double fabs (double __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern double __fabs (double __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));


extern double floor (double __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern double __floor (double __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));


extern double fmod (double __x, double __y) __attribute__ ((__nothrow__ )); extern double __fmod (double __x, double __y) __attribute__ ((__nothrow__ ));
# 177 "../math/bits/mathcalls.h"
extern int isinf (double __value) __attribute__ ((__nothrow__ ))
  __attribute__ ((__const__));




extern int finite (double __value) __attribute__ ((__nothrow__ ))
  __attribute__ ((__const__));


extern double drem (double __x, double __y) __attribute__ ((__nothrow__ )); extern double __drem (double __x, double __y) __attribute__ ((__nothrow__ ));



extern double significand (double __x) __attribute__ ((__nothrow__ )); extern double __significand (double __x) __attribute__ ((__nothrow__ ));






extern double copysign (double __x, double __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern double __copysign (double __x, double __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));




extern double nan (const char *__tagb) __attribute__ ((__nothrow__ )); extern double __nan (const char *__tagb) __attribute__ ((__nothrow__ ));
# 213 "../math/bits/mathcalls.h"
extern int isnan (double __value) __attribute__ ((__nothrow__ ))
  __attribute__ ((__const__));





extern double j0 (double) __attribute__ ((__nothrow__ )); extern double __j0 (double) __attribute__ ((__nothrow__ ));
extern double j1 (double) __attribute__ ((__nothrow__ )); extern double __j1 (double) __attribute__ ((__nothrow__ ));
extern double jn (int, double) __attribute__ ((__nothrow__ )); extern double __jn (int, double) __attribute__ ((__nothrow__ ));
extern double y0 (double) __attribute__ ((__nothrow__ )); extern double __y0 (double) __attribute__ ((__nothrow__ ));
extern double y1 (double) __attribute__ ((__nothrow__ )); extern double __y1 (double) __attribute__ ((__nothrow__ ));
extern double yn (int, double) __attribute__ ((__nothrow__ )); extern double __yn (int, double) __attribute__ ((__nothrow__ ));





extern double erf (double) __attribute__ ((__nothrow__ )); extern double __erf (double) __attribute__ ((__nothrow__ ));
extern double erfc (double) __attribute__ ((__nothrow__ )); extern double __erfc (double) __attribute__ ((__nothrow__ ));
extern double lgamma (double) __attribute__ ((__nothrow__ )); extern double __lgamma (double) __attribute__ ((__nothrow__ ));




extern double tgamma (double) __attribute__ ((__nothrow__ )); extern double __tgamma (double) __attribute__ ((__nothrow__ ));





extern double gamma (double) __attribute__ ((__nothrow__ )); extern double __gamma (double) __attribute__ ((__nothrow__ ));







extern double lgamma_r (double, int *__signgamp) __attribute__ ((__nothrow__ )); extern double __lgamma_r (double, int *__signgamp) __attribute__ ((__nothrow__ ));






extern double rint (double __x) __attribute__ ((__nothrow__ )); extern double __rint (double __x) __attribute__ ((__nothrow__ ));


extern double nextafter (double __x, double __y) __attribute__ ((__nothrow__ )); extern double __nextafter (double __x, double __y) __attribute__ ((__nothrow__ ));

extern double nexttoward (double __x, long double __y) __attribute__ ((__nothrow__ )); extern double __nexttoward (double __x, long double __y) __attribute__ ((__nothrow__ ));




extern double nextdown (double __x) __attribute__ ((__nothrow__ )); extern double __nextdown (double __x) __attribute__ ((__nothrow__ ));

extern double nextup (double __x) __attribute__ ((__nothrow__ )); extern double __nextup (double __x) __attribute__ ((__nothrow__ ));



extern double remainder (double __x, double __y) __attribute__ ((__nothrow__ )); extern double __remainder (double __x, double __y) __attribute__ ((__nothrow__ ));



extern double scalbn (double __x, int __n) __attribute__ ((__nothrow__ )); extern double __scalbn (double __x, int __n) __attribute__ ((__nothrow__ ));



extern int ilogb (double __x) __attribute__ ((__nothrow__ )); extern int __ilogb (double __x) __attribute__ ((__nothrow__ ));




extern long int llogb (double __x) __attribute__ ((__nothrow__ )); extern long int __llogb (double __x) __attribute__ ((__nothrow__ ));




extern double scalbln (double __x, long int __n) __attribute__ ((__nothrow__ )); extern double __scalbln (double __x, long int __n) __attribute__ ((__nothrow__ ));



extern double nearbyint (double __x) __attribute__ ((__nothrow__ )); extern double __nearbyint (double __x) __attribute__ ((__nothrow__ ));



extern double round (double __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern double __round (double __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));



extern double trunc (double __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern double __trunc (double __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));




extern double remquo (double __x, double __y, int *__quo) __attribute__ ((__nothrow__ )); extern double __remquo (double __x, double __y, int *__quo) __attribute__ ((__nothrow__ ));






extern long int lrint (double __x) __attribute__ ((__nothrow__ )); extern long int __lrint (double __x) __attribute__ ((__nothrow__ ));
__extension__
extern long long int llrint (double __x) __attribute__ ((__nothrow__ )); extern long long int __llrint (double __x) __attribute__ ((__nothrow__ ));



extern long int lround (double __x) __attribute__ ((__nothrow__ )); extern long int __lround (double __x) __attribute__ ((__nothrow__ ));
__extension__
extern long long int llround (double __x) __attribute__ ((__nothrow__ )); extern long long int __llround (double __x) __attribute__ ((__nothrow__ ));



extern double fdim (double __x, double __y) __attribute__ ((__nothrow__ )); extern double __fdim (double __x, double __y) __attribute__ ((__nothrow__ ));


extern double fmax (double __x, double __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern double __fmax (double __x, double __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));


extern double fmin (double __x, double __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern double __fmin (double __x, double __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));


extern double fma (double __x, double __y, double __z) __attribute__ ((__nothrow__ )); extern double __fma (double __x, double __y, double __z) __attribute__ ((__nothrow__ ));




extern double roundeven (double __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern double __roundeven (double __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));



extern __intmax_t fromfp (double __x, int __round, unsigned int __width) __attribute__ ((__nothrow__ )); extern __intmax_t __fromfp (double __x, int __round, unsigned int __width) __attribute__ ((__nothrow__ ))
                            ;



extern __uintmax_t ufromfp (double __x, int __round, unsigned int __width) __attribute__ ((__nothrow__ )); extern __uintmax_t __ufromfp (double __x, int __round, unsigned int __width) __attribute__ ((__nothrow__ ))
                              ;




extern __intmax_t fromfpx (double __x, int __round, unsigned int __width) __attribute__ ((__nothrow__ )); extern __intmax_t __fromfpx (double __x, int __round, unsigned int __width) __attribute__ ((__nothrow__ ))
                             ;




extern __uintmax_t ufromfpx (double __x, int __round, unsigned int __width) __attribute__ ((__nothrow__ )); extern __uintmax_t __ufromfpx (double __x, int __round, unsigned int __width) __attribute__ ((__nothrow__ ))
                               ;


extern int canonicalize (double *__cx, const double *__x) __attribute__ ((__nothrow__ ));






extern double fmaxmag (double __x, double __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern double __fmaxmag (double __x, double __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));


extern double fminmag (double __x, double __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern double __fminmag (double __x, double __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));




extern int totalorder (const double *__x, const double *__y) __attribute__ ((__nothrow__ ))

     __attribute__ ((__pure__));


extern int totalordermag (const double *__x, const double *__y) __attribute__ ((__nothrow__ ))

     __attribute__ ((__pure__));


extern double getpayload (const double *__x) __attribute__ ((__nothrow__ )); extern double __getpayload (const double *__x) __attribute__ ((__nothrow__ ));


extern int setpayload (double *__x, double __payload) __attribute__ ((__nothrow__ ));


extern int setpayloadsig (double *__x, double __payload) __attribute__ ((__nothrow__ ));







extern double scalb (double __x, double __n) __attribute__ ((__nothrow__ )); extern double __scalb (double __x, double __n) __attribute__ ((__nothrow__ ));
# 2 "../include/bits/mathcalls.h" 2
# 314 "../math/math.h" 2
# 329 "../math/math.h"
# 1 "../include/bits/mathcalls-helper-functions.h" 1
# 1 "../math/bits/mathcalls-helper-functions.h" 1
# 20 "../math/bits/mathcalls-helper-functions.h"
extern int __fpclassifyf (float __value) __attribute__ ((__nothrow__ ))
     __attribute__ ((__const__));


extern int __signbitf (float __value) __attribute__ ((__nothrow__ ))
     __attribute__ ((__const__));



extern int __isinff (float __value) __attribute__ ((__nothrow__ ))
  __attribute__ ((__const__));


extern int __finitef (float __value) __attribute__ ((__nothrow__ ))
  __attribute__ ((__const__));


extern int __isnanf (float __value) __attribute__ ((__nothrow__ ))
  __attribute__ ((__const__));


extern int __iseqsigf (float __x, float __y) __attribute__ ((__nothrow__ ));


extern int __issignalingf (float __value) __attribute__ ((__nothrow__ ))
     __attribute__ ((__const__));
# 2 "../include/bits/mathcalls-helper-functions.h" 2
# 330 "../math/math.h" 2
# 1 "../include/bits/mathcalls.h" 1
# 1 "../math/bits/mathcalls.h" 1
# 53 "../math/bits/mathcalls.h"
extern float acosf (float __x) __attribute__ ((__nothrow__ )); extern float __acosf (float __x) __attribute__ ((__nothrow__ ));

extern float asinf (float __x) __attribute__ ((__nothrow__ )); extern float __asinf (float __x) __attribute__ ((__nothrow__ ));

extern float atanf (float __x) __attribute__ ((__nothrow__ )); extern float __atanf (float __x) __attribute__ ((__nothrow__ ));

extern float atan2f (float __y, float __x) __attribute__ ((__nothrow__ )); extern float __atan2f (float __y, float __x) __attribute__ ((__nothrow__ ));


 extern float cosf (float __x) __attribute__ ((__nothrow__ )); extern float __cosf (float __x) __attribute__ ((__nothrow__ ));

 extern float sinf (float __x) __attribute__ ((__nothrow__ )); extern float __sinf (float __x) __attribute__ ((__nothrow__ ));

extern float tanf (float __x) __attribute__ ((__nothrow__ )); extern float __tanf (float __x) __attribute__ ((__nothrow__ ));




extern float coshf (float __x) __attribute__ ((__nothrow__ )); extern float __coshf (float __x) __attribute__ ((__nothrow__ ));

extern float sinhf (float __x) __attribute__ ((__nothrow__ )); extern float __sinhf (float __x) __attribute__ ((__nothrow__ ));

extern float tanhf (float __x) __attribute__ ((__nothrow__ )); extern float __tanhf (float __x) __attribute__ ((__nothrow__ ));



 extern void sincosf (float __x, float *__sinx, float *__cosx) __attribute__ ((__nothrow__ )); extern void __sincosf (float __x, float *__sinx, float *__cosx) __attribute__ ((__nothrow__ ))
                                                        ;




extern float acoshf (float __x) __attribute__ ((__nothrow__ )); extern float __acoshf (float __x) __attribute__ ((__nothrow__ ));

extern float asinhf (float __x) __attribute__ ((__nothrow__ )); extern float __asinhf (float __x) __attribute__ ((__nothrow__ ));

extern float atanhf (float __x) __attribute__ ((__nothrow__ )); extern float __atanhf (float __x) __attribute__ ((__nothrow__ ));





 extern float expf (float __x) __attribute__ ((__nothrow__ )); extern float __expf (float __x) __attribute__ ((__nothrow__ ));


extern float frexpf (float __x, int *__exponent) __attribute__ ((__nothrow__ )); extern float __frexpf (float __x, int *__exponent) __attribute__ ((__nothrow__ ));


extern float ldexpf (float __x, int __exponent) __attribute__ ((__nothrow__ )); extern float __ldexpf (float __x, int __exponent) __attribute__ ((__nothrow__ ));


 extern float logf (float __x) __attribute__ ((__nothrow__ )); extern float __logf (float __x) __attribute__ ((__nothrow__ ));


extern float log10f (float __x) __attribute__ ((__nothrow__ )); extern float __log10f (float __x) __attribute__ ((__nothrow__ ));


extern float modff (float __x, float *__iptr) __attribute__ ((__nothrow__ )); extern float __modff (float __x, float *__iptr) __attribute__ ((__nothrow__ )) ;



extern float exp10f (float __x) __attribute__ ((__nothrow__ )); extern float __exp10f (float __x) __attribute__ ((__nothrow__ ));




extern float expm1f (float __x) __attribute__ ((__nothrow__ )); extern float __expm1f (float __x) __attribute__ ((__nothrow__ ));


extern float log1pf (float __x) __attribute__ ((__nothrow__ )); extern float __log1pf (float __x) __attribute__ ((__nothrow__ ));


extern float logbf (float __x) __attribute__ ((__nothrow__ )); extern float __logbf (float __x) __attribute__ ((__nothrow__ ));




extern float exp2f (float __x) __attribute__ ((__nothrow__ )); extern float __exp2f (float __x) __attribute__ ((__nothrow__ ));


extern float log2f (float __x) __attribute__ ((__nothrow__ )); extern float __log2f (float __x) __attribute__ ((__nothrow__ ));






 extern float powf (float __x, float __y) __attribute__ ((__nothrow__ )); extern float __powf (float __x, float __y) __attribute__ ((__nothrow__ ));


extern float sqrtf (float __x) __attribute__ ((__nothrow__ )); extern float __sqrtf (float __x) __attribute__ ((__nothrow__ ));



extern float hypotf (float __x, float __y) __attribute__ ((__nothrow__ )); extern float __hypotf (float __x, float __y) __attribute__ ((__nothrow__ ));




extern float cbrtf (float __x) __attribute__ ((__nothrow__ )); extern float __cbrtf (float __x) __attribute__ ((__nothrow__ ));






extern float ceilf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern float __ceilf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));


extern float fabsf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern float __fabsf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));


extern float floorf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern float __floorf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));


extern float fmodf (float __x, float __y) __attribute__ ((__nothrow__ )); extern float __fmodf (float __x, float __y) __attribute__ ((__nothrow__ ));
# 177 "../math/bits/mathcalls.h"
extern int isinff (float __value) __attribute__ ((__nothrow__ ))
  __attribute__ ((__const__));




extern int finitef (float __value) __attribute__ ((__nothrow__ ))
  __attribute__ ((__const__));


extern float dremf (float __x, float __y) __attribute__ ((__nothrow__ )); extern float __dremf (float __x, float __y) __attribute__ ((__nothrow__ ));



extern float significandf (float __x) __attribute__ ((__nothrow__ )); extern float __significandf (float __x) __attribute__ ((__nothrow__ ));






extern float copysignf (float __x, float __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern float __copysignf (float __x, float __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));




extern float nanf (const char *__tagb) __attribute__ ((__nothrow__ )); extern float __nanf (const char *__tagb) __attribute__ ((__nothrow__ ));
# 213 "../math/bits/mathcalls.h"
extern int isnanf (float __value) __attribute__ ((__nothrow__ ))
  __attribute__ ((__const__));





extern float j0f (float) __attribute__ ((__nothrow__ )); extern float __j0f (float) __attribute__ ((__nothrow__ ));
extern float j1f (float) __attribute__ ((__nothrow__ )); extern float __j1f (float) __attribute__ ((__nothrow__ ));
extern float jnf (int, float) __attribute__ ((__nothrow__ )); extern float __jnf (int, float) __attribute__ ((__nothrow__ ));
extern float y0f (float) __attribute__ ((__nothrow__ )); extern float __y0f (float) __attribute__ ((__nothrow__ ));
extern float y1f (float) __attribute__ ((__nothrow__ )); extern float __y1f (float) __attribute__ ((__nothrow__ ));
extern float ynf (int, float) __attribute__ ((__nothrow__ )); extern float __ynf (int, float) __attribute__ ((__nothrow__ ));





extern float erff (float) __attribute__ ((__nothrow__ )); extern float __erff (float) __attribute__ ((__nothrow__ ));
extern float erfcf (float) __attribute__ ((__nothrow__ )); extern float __erfcf (float) __attribute__ ((__nothrow__ ));
extern float lgammaf (float) __attribute__ ((__nothrow__ )); extern float __lgammaf (float) __attribute__ ((__nothrow__ ));




extern float tgammaf (float) __attribute__ ((__nothrow__ )); extern float __tgammaf (float) __attribute__ ((__nothrow__ ));





extern float gammaf (float) __attribute__ ((__nothrow__ )); extern float __gammaf (float) __attribute__ ((__nothrow__ ));







extern float lgammaf_r (float, int *__signgamp) __attribute__ ((__nothrow__ )); extern float __lgammaf_r (float, int *__signgamp) __attribute__ ((__nothrow__ ));






extern float rintf (float __x) __attribute__ ((__nothrow__ )); extern float __rintf (float __x) __attribute__ ((__nothrow__ ));


extern float nextafterf (float __x, float __y) __attribute__ ((__nothrow__ )); extern float __nextafterf (float __x, float __y) __attribute__ ((__nothrow__ ));

extern float nexttowardf (float __x, long double __y) __attribute__ ((__nothrow__ )); extern float __nexttowardf (float __x, long double __y) __attribute__ ((__nothrow__ ));




extern float nextdownf (float __x) __attribute__ ((__nothrow__ )); extern float __nextdownf (float __x) __attribute__ ((__nothrow__ ));

extern float nextupf (float __x) __attribute__ ((__nothrow__ )); extern float __nextupf (float __x) __attribute__ ((__nothrow__ ));



extern float remainderf (float __x, float __y) __attribute__ ((__nothrow__ )); extern float __remainderf (float __x, float __y) __attribute__ ((__nothrow__ ));



extern float scalbnf (float __x, int __n) __attribute__ ((__nothrow__ )); extern float __scalbnf (float __x, int __n) __attribute__ ((__nothrow__ ));



extern int ilogbf (float __x) __attribute__ ((__nothrow__ )); extern int __ilogbf (float __x) __attribute__ ((__nothrow__ ));




extern long int llogbf (float __x) __attribute__ ((__nothrow__ )); extern long int __llogbf (float __x) __attribute__ ((__nothrow__ ));




extern float scalblnf (float __x, long int __n) __attribute__ ((__nothrow__ )); extern float __scalblnf (float __x, long int __n) __attribute__ ((__nothrow__ ));



extern float nearbyintf (float __x) __attribute__ ((__nothrow__ )); extern float __nearbyintf (float __x) __attribute__ ((__nothrow__ ));



extern float roundf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern float __roundf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));



extern float truncf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern float __truncf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));




extern float remquof (float __x, float __y, int *__quo) __attribute__ ((__nothrow__ )); extern float __remquof (float __x, float __y, int *__quo) __attribute__ ((__nothrow__ ));






extern long int lrintf (float __x) __attribute__ ((__nothrow__ )); extern long int __lrintf (float __x) __attribute__ ((__nothrow__ ));
__extension__
extern long long int llrintf (float __x) __attribute__ ((__nothrow__ )); extern long long int __llrintf (float __x) __attribute__ ((__nothrow__ ));



extern long int lroundf (float __x) __attribute__ ((__nothrow__ )); extern long int __lroundf (float __x) __attribute__ ((__nothrow__ ));
__extension__
extern long long int llroundf (float __x) __attribute__ ((__nothrow__ )); extern long long int __llroundf (float __x) __attribute__ ((__nothrow__ ));



extern float fdimf (float __x, float __y) __attribute__ ((__nothrow__ )); extern float __fdimf (float __x, float __y) __attribute__ ((__nothrow__ ));


extern float fmaxf (float __x, float __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern float __fmaxf (float __x, float __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));


extern float fminf (float __x, float __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern float __fminf (float __x, float __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));


extern float fmaf (float __x, float __y, float __z) __attribute__ ((__nothrow__ )); extern float __fmaf (float __x, float __y, float __z) __attribute__ ((__nothrow__ ));




extern float roundevenf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern float __roundevenf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));



extern __intmax_t fromfpf (float __x, int __round, unsigned int __width) __attribute__ ((__nothrow__ )); extern __intmax_t __fromfpf (float __x, int __round, unsigned int __width) __attribute__ ((__nothrow__ ))
                            ;



extern __uintmax_t ufromfpf (float __x, int __round, unsigned int __width) __attribute__ ((__nothrow__ )); extern __uintmax_t __ufromfpf (float __x, int __round, unsigned int __width) __attribute__ ((__nothrow__ ))
                              ;




extern __intmax_t fromfpxf (float __x, int __round, unsigned int __width) __attribute__ ((__nothrow__ )); extern __intmax_t __fromfpxf (float __x, int __round, unsigned int __width) __attribute__ ((__nothrow__ ))
                             ;




extern __uintmax_t ufromfpxf (float __x, int __round, unsigned int __width) __attribute__ ((__nothrow__ )); extern __uintmax_t __ufromfpxf (float __x, int __round, unsigned int __width) __attribute__ ((__nothrow__ ))
                               ;


extern int canonicalizef (float *__cx, const float *__x) __attribute__ ((__nothrow__ ));






extern float fmaxmagf (float __x, float __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern float __fmaxmagf (float __x, float __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));


extern float fminmagf (float __x, float __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern float __fminmagf (float __x, float __y) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));




extern int totalorderf (const float *__x, const float *__y) __attribute__ ((__nothrow__ ))

     __attribute__ ((__pure__));


extern int totalordermagf (const float *__x, const float *__y) __attribute__ ((__nothrow__ ))

     __attribute__ ((__pure__));


extern float getpayloadf (const float *__x) __attribute__ ((__nothrow__ )); extern float __getpayloadf (const float *__x) __attribute__ ((__nothrow__ ));


extern int setpayloadf (float *__x, float __payload) __attribute__ ((__nothrow__ ));


extern int setpayloadsigf (float *__x, float __payload) __attribute__ ((__nothrow__ ));







extern float scalbf (float __x, float __n) __attribute__ ((__nothrow__ )); extern float __scalbf (float __x, float __n) __attribute__ ((__nothrow__ ));
# 2 "../include/bits/mathcalls.h" 2
# 331 "../math/math.h" 2
# 566 "../math/math.h"
# 1 "../include/bits/mathcalls-narrow.h" 1
# 1 "../math/bits/mathcalls-narrow.h" 1
# 24 "../math/bits/mathcalls-narrow.h"
extern float fadd (double __x, double __y) __attribute__ ((__nothrow__ ));


extern float fdiv (double __x, double __y) __attribute__ ((__nothrow__ ));


extern float fmul (double __x, double __y) __attribute__ ((__nothrow__ ));


extern float fsqrt (double __x) __attribute__ ((__nothrow__ ));


extern float fsub (double __x, double __y) __attribute__ ((__nothrow__ ));
# 2 "../include/bits/mathcalls-narrow.h" 2
# 567 "../math/math.h" 2
# 587 "../math/math.h"
# 1 "../include/bits/mathcalls-narrow.h" 1
# 1 "../math/bits/mathcalls-narrow.h" 1
# 24 "../math/bits/mathcalls-narrow.h"
extern float faddl (long double __x, long double __y) __attribute__ ((__nothrow__ ));


extern float fdivl (long double __x, long double __y) __attribute__ ((__nothrow__ ));


extern float fmull (long double __x, long double __y) __attribute__ ((__nothrow__ ));


extern float fsqrtl (long double __x) __attribute__ ((__nothrow__ ));


extern float fsubl (long double __x, long double __y) __attribute__ ((__nothrow__ ));
# 2 "../include/bits/mathcalls-narrow.h" 2
# 588 "../math/math.h" 2
# 616 "../math/math.h"
# 1 "../include/bits/mathcalls-narrow.h" 1
# 1 "../math/bits/mathcalls-narrow.h" 1
# 24 "../math/bits/mathcalls-narrow.h"
extern double daddl (long double __x, long double __y) __attribute__ ((__nothrow__ ));


extern double ddivl (long double __x, long double __y) __attribute__ ((__nothrow__ ));


extern double dmull (long double __x, long double __y) __attribute__ ((__nothrow__ ));


extern double dsqrtl (long double __x) __attribute__ ((__nothrow__ ));


extern double dsubl (long double __x, long double __y) __attribute__ ((__nothrow__ ));
# 2 "../include/bits/mathcalls-narrow.h" 2
# 617 "../math/math.h" 2
# 697 "../math/math.h"
# 1 "../include/bits/mathcalls-narrow.h" 1
# 1 "../math/bits/mathcalls-narrow.h" 1
# 24 "../math/bits/mathcalls-narrow.h"
extern _Float32 f32addf32x (_Float32x __x, _Float32x __y) __attribute__ ((__nothrow__ ));


extern _Float32 f32divf32x (_Float32x __x, _Float32x __y) __attribute__ ((__nothrow__ ));


extern _Float32 f32mulf32x (_Float32x __x, _Float32x __y) __attribute__ ((__nothrow__ ));


extern _Float32 f32sqrtf32x (_Float32x __x) __attribute__ ((__nothrow__ ));


extern _Float32 f32subf32x (_Float32x __x, _Float32x __y) __attribute__ ((__nothrow__ ));
# 2 "../include/bits/mathcalls-narrow.h" 2
# 698 "../math/math.h" 2
# 707 "../math/math.h"
# 1 "../include/bits/mathcalls-narrow.h" 1
# 1 "../math/bits/mathcalls-narrow.h" 1
# 24 "../math/bits/mathcalls-narrow.h"
extern _Float32 f32addf64 (_Float64 __x, _Float64 __y) __attribute__ ((__nothrow__ ));


extern _Float32 f32divf64 (_Float64 __x, _Float64 __y) __attribute__ ((__nothrow__ ));


extern _Float32 f32mulf64 (_Float64 __x, _Float64 __y) __attribute__ ((__nothrow__ ));


extern _Float32 f32sqrtf64 (_Float64 __x) __attribute__ ((__nothrow__ ));


extern _Float32 f32subf64 (_Float64 __x, _Float64 __y) __attribute__ ((__nothrow__ ));
# 2 "../include/bits/mathcalls-narrow.h" 2
# 708 "../math/math.h" 2
# 747 "../math/math.h"
# 1 "../include/bits/mathcalls-narrow.h" 1
# 1 "../math/bits/mathcalls-narrow.h" 1
# 24 "../math/bits/mathcalls-narrow.h"
extern _Float32x f32xaddf64 (_Float64 __x, _Float64 __y) __attribute__ ((__nothrow__ ));


extern _Float32x f32xdivf64 (_Float64 __x, _Float64 __y) __attribute__ ((__nothrow__ ));


extern _Float32x f32xmulf64 (_Float64 __x, _Float64 __y) __attribute__ ((__nothrow__ ));


extern _Float32x f32xsqrtf64 (_Float64 __x) __attribute__ ((__nothrow__ ));


extern _Float32x f32xsubf64 (_Float64 __x, _Float64 __y) __attribute__ ((__nothrow__ ));
# 2 "../include/bits/mathcalls-narrow.h" 2
# 748 "../math/math.h" 2
# 854 "../math/math.h"
extern int signgam;
# 934 "../math/math.h"
enum
  {
    FP_NAN =

      0,
    FP_INFINITE =

      1,
    FP_ZERO =

      2,
    FP_SUBNORMAL =

      3,
    FP_NORMAL =

      4
  };
# 1054 "../math/math.h"
# 1 "../bits/iscanonical.h" 1
# 1055 "../math/math.h" 2
# 1406 "../math/math.h"

# 8 "../include/math.h" 2



extern int __signgam;








# 35 "../include/math.h"






# 57 "../include/math.h"
# 1 "../include/stdint.h" 1
# 1 "../stdlib/stdint.h" 1
# 26 "../stdlib/stdint.h"
# 1 "../bits/libc-header-start.h" 1
# 27 "../stdlib/stdint.h" 2
# 1 "../include/bits/types.h" 1
# 28 "../stdlib/stdint.h" 2
# 1 "../bits/wchar.h" 1
# 29 "../stdlib/stdint.h" 2
# 1 "../sysdeps/wordsize-32/bits/wordsize.h" 1
# 30 "../stdlib/stdint.h" 2




# 1 "../bits/stdint-intn.h" 1
# 22 "../bits/stdint-intn.h"
# 1 "../include/bits/types.h" 1
# 23 "../bits/stdint-intn.h" 2

typedef __int8_t int8_t;
typedef __int16_t int16_t;
typedef __int32_t int32_t;
typedef __int64_t int64_t;
# 35 "../stdlib/stdint.h" 2


# 1 "../bits/stdint-uintn.h" 1
# 22 "../bits/stdint-uintn.h"
# 1 "../include/bits/types.h" 1
# 23 "../bits/stdint-uintn.h" 2

typedef __uint8_t uint8_t;
typedef __uint16_t uint16_t;
typedef __uint32_t uint32_t;
typedef __uint64_t uint64_t;
# 38 "../stdlib/stdint.h" 2





typedef __int_least8_t int_least8_t;
typedef __int_least16_t int_least16_t;
typedef __int_least32_t int_least32_t;
typedef __int_least64_t int_least64_t;


typedef __uint_least8_t uint_least8_t;
typedef __uint_least16_t uint_least16_t;
typedef __uint_least32_t uint_least32_t;
typedef __uint_least64_t uint_least64_t;





typedef signed char int_fast8_t;





typedef int int_fast16_t;
typedef int int_fast32_t;
__extension__
typedef long long int int_fast64_t;



typedef unsigned char uint_fast8_t;





typedef unsigned int uint_fast16_t;
typedef unsigned int uint_fast32_t;
__extension__
typedef unsigned long long int uint_fast64_t;
# 93 "../stdlib/stdint.h"
typedef int intptr_t;


typedef unsigned int uintptr_t;




typedef __intmax_t intmax_t;
typedef __uintmax_t uintmax_t;
# 2 "../include/stdint.h" 2
# 58 "../include/math.h" 2
# 1 "../sysdeps/generic/nan-high-order-bit.h" 1
# 59 "../include/math.h" 2




typedef union
{
  float value;
  uint32_t word;
} ieee_float_shape_type;
# 89 "../include/math.h"
extern inline int
__issignalingf (float x)
{
  uint32_t xi;
  do { ieee_float_shape_type gf_u; gf_u.value = (x); (xi) = gf_u.word; } while (0);
# 103 "../include/math.h"
  xi ^= 0x00400000;


  return (xi & 0x7fffffff) > 0x7fc00000;

}
# 30 "../sysdeps/ieee754/soft-fp/s_fmaf.c" 2
# 1 "../include/libc-diag.h" 1
# 31 "../sysdeps/ieee754/soft-fp/s_fmaf.c" 2
# 1 "../sysdeps/generic/libm-alias-float.h" 1
# 22 "../sysdeps/generic/libm-alias-float.h"
# 1 "../bits/floatn.h" 1
# 23 "../sysdeps/generic/libm-alias-float.h" 2
# 32 "../sysdeps/ieee754/soft-fp/s_fmaf.c" 2








# 39 "../sysdeps/ieee754/soft-fp/s_fmaf.c"
#pragma GCC diagnostic push
# 39 "../sysdeps/ieee754/soft-fp/s_fmaf.c"
;

# 40 "../sysdeps/ieee754/soft-fp/s_fmaf.c"
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
# 40 "../sysdeps/ieee754/soft-fp/s_fmaf.c"
;

# 1 "../soft-fp/soft-fp.h" 1
# 32 "../soft-fp/soft-fp.h"
# 1 "../sysdeps/nios2/sfp-machine.h" 1
# 33 "../soft-fp/soft-fp.h" 2
# 44 "../soft-fp/soft-fp.h"
# 1 "../include/endian.h" 1
# 1 "../string/endian.h" 1
# 24 "../string/endian.h"
# 1 "../include/bits/endian.h" 1
# 1 "../string/bits/endian.h" 1
# 35 "../string/bits/endian.h"
# 1 "../sysdeps/nios2/bits/endianness.h" 1
# 36 "../string/bits/endian.h" 2
# 2 "../include/bits/endian.h" 2
# 25 "../string/endian.h" 2
# 35 "../string/endian.h"
# 1 "../bits/byteswap.h" 1
# 27 "../bits/byteswap.h"
# 1 "../include/bits/types.h" 1
# 28 "../bits/byteswap.h" 2





static __inline __uint16_t
__bswap_16 (__uint16_t __bsx)
{

  return __builtin_bswap16 (__bsx);



}






static __inline __uint32_t
__bswap_32 (__uint32_t __bsx)
{

  return __builtin_bswap32 (__bsx);



}
# 69 "../bits/byteswap.h"
__extension__ static __inline __uint64_t
__bswap_64 (__uint64_t __bsx)
{

  return __builtin_bswap64 (__bsx);



}
# 36 "../string/endian.h" 2
# 1 "../bits/uintn-identity.h" 1
# 26 "../bits/uintn-identity.h"
# 1 "../include/bits/types.h" 1
# 27 "../bits/uintn-identity.h" 2





static __inline __uint16_t
__uint16_identity (__uint16_t __x)
{
  return __x;
}

static __inline __uint32_t
__uint32_identity (__uint32_t __x)
{
  return __x;
}

static __inline __uint64_t
__uint64_identity (__uint64_t __x)
{
  return __x;
}
# 37 "../string/endian.h" 2
# 2 "../include/endian.h" 2
# 45 "../soft-fp/soft-fp.h" 2
# 313 "../soft-fp/soft-fp.h"
# 1 "../soft-fp/op-1.h" 1
# 314 "../soft-fp/soft-fp.h" 2
# 1 "../soft-fp/op-2.h" 1
# 315 "../soft-fp/soft-fp.h" 2
# 1 "../soft-fp/op-4.h" 1
# 316 "../soft-fp/soft-fp.h" 2
# 1 "../soft-fp/op-8.h" 1
# 317 "../soft-fp/soft-fp.h" 2
# 1 "../soft-fp/op-common.h" 1
# 318 "../soft-fp/soft-fp.h" 2





typedef int QItype __attribute__ ((mode (QI)));
typedef int SItype __attribute__ ((mode (SI)));
typedef int DItype __attribute__ ((mode (DI)));
typedef unsigned int UQItype __attribute__ ((mode (QI)));
typedef unsigned int USItype __attribute__ ((mode (SI)));
typedef unsigned int UDItype __attribute__ ((mode (DI)));

typedef unsigned int UHWtype __attribute__ ((mode (HI)));
# 344 "../soft-fp/soft-fp.h"
# 1 "../stdlib/longlong.h" 1
# 60 "../stdlib/longlong.h"
extern const UQItype __clz_tab[256] ;
# 345 "../soft-fp/soft-fp.h" 2
# 43 "../sysdeps/ieee754/soft-fp/s_fmaf.c" 2
# 1 "../soft-fp/single.h" 1
# 65 "../soft-fp/single.h"
typedef float SFtype __attribute__ ((mode (SF)));

union _FP_UNION_S
{
  SFtype flt;
  struct
  {





    unsigned frac : 24 - (((unsigned long) 1 << (24 -1)) != 0);
    unsigned exp : 8;
    unsigned sign : 1;

  } bits;
};
# 44 "../sysdeps/ieee754/soft-fp/s_fmaf.c" 2

float
__fmaf (float a, float b, float c)
{
  int _fex = 0;
  long A_c __attribute__ ((unused)) ; long A_s __attribute__ ((unused)) ; long A_e __attribute__ ((unused)) ; unsigned long A_f ;
  long B_c __attribute__ ((unused)) ; long B_s __attribute__ ((unused)) ; long B_e __attribute__ ((unused)) ; unsigned long B_f ;
  long C_c __attribute__ ((unused)) ; long C_s __attribute__ ((unused)) ; long C_e __attribute__ ((unused)) ; unsigned long C_f ;
  long R_c __attribute__ ((unused)) ; long R_s __attribute__ ((unused)) ; long R_e __attribute__ ((unused)) ; unsigned long R_f ;
  float r;

  do {} while (0);
  do { do { union _FP_UNION_S _FP_UNPACK_RAW_1_flo; _FP_UNPACK_RAW_1_flo.flt = ((a)); A_f = _FP_UNPACK_RAW_1_flo.bits.frac; A_e = _FP_UNPACK_RAW_1_flo.bits.exp; A_s = _FP_UNPACK_RAW_1_flo.bits.sign; } while (0); do { switch (A_e) { default: (A_f) |= ((unsigned long) 1 << (24 -1)); do { if (__builtin_constant_p (3) && (3) == 1) A_f += A_f; else A_f <<= (3); } while (0); A_e -= 127; A_c = 0; break; case 0: if ((A_f == 0)) A_c = 1; else if (0) { A_c = 1; (A_f = 0); _fex |= (0); } else { long _FP_UNPACK_CANONICAL_shift; do { _Static_assert (((sizeof (unsigned long) == sizeof (unsigned int) || (sizeof (unsigned long) == sizeof (unsigned long)) || (sizeof (unsigned long) == sizeof (unsigned long long)))), "_FP_W_TYPE size unsupported for clz"); if (sizeof (unsigned long) == sizeof (unsigned int)) ((_FP_UNPACK_CANONICAL_shift)) = __builtin_clz (A_f); else if (sizeof (unsigned long) == sizeof (unsigned long)) ((_FP_UNPACK_CANONICAL_shift)) = __builtin_clzl (A_f); else ((_FP_UNPACK_CANONICAL_shift)) = __builtin_clzll (A_f); } while (0); _FP_UNPACK_CANONICAL_shift -= (32 - 24); do { if (__builtin_constant_p ((_FP_UNPACK_CANONICAL_shift + 3)) && ((_FP_UNPACK_CANONICAL_shift + 3)) == 1) A_f += A_f; else A_f <<= ((_FP_UNPACK_CANONICAL_shift + 3)); } while (0); A_e -= (127 - 1 + _FP_UNPACK_CANONICAL_shift); A_c = 0; _fex |= (0); } break; case 255: if ((A_f == 0)) A_c = 2; else { A_c = 3; if (((0) ? ((A_f) & ((unsigned long) 1 << (24 -2))) : !((A_f) & ((unsigned long) 1 << (24 -2))))) _fex |= (0 | 0); } break; } } while (0); } while (0);
  do { do { union _FP_UNION_S _FP_UNPACK_RAW_1_flo; _FP_UNPACK_RAW_1_flo.flt = ((b)); B_f = _FP_UNPACK_RAW_1_flo.bits.frac; B_e = _FP_UNPACK_RAW_1_flo.bits.exp; B_s = _FP_UNPACK_RAW_1_flo.bits.sign; } while (0); do { switch (B_e) { default: (B_f) |= ((unsigned long) 1 << (24 -1)); do { if (__builtin_constant_p (3) && (3) == 1) B_f += B_f; else B_f <<= (3); } while (0); B_e -= 127; B_c = 0; break; case 0: if ((B_f == 0)) B_c = 1; else if (0) { B_c = 1; (B_f = 0); _fex |= (0); } else { long _FP_UNPACK_CANONICAL_shift; do { _Static_assert (((sizeof (unsigned long) == sizeof (unsigned int) || (sizeof (unsigned long) == sizeof (unsigned long)) || (sizeof (unsigned long) == sizeof (unsigned long long)))), "_FP_W_TYPE size unsupported for clz"); if (sizeof (unsigned long) == sizeof (unsigned int)) ((_FP_UNPACK_CANONICAL_shift)) = __builtin_clz (B_f); else if (sizeof (unsigned long) == sizeof (unsigned long)) ((_FP_UNPACK_CANONICAL_shift)) = __builtin_clzl (B_f); else ((_FP_UNPACK_CANONICAL_shift)) = __builtin_clzll (B_f); } while (0); _FP_UNPACK_CANONICAL_shift -= (32 - 24); do { if (__builtin_constant_p ((_FP_UNPACK_CANONICAL_shift + 3)) && ((_FP_UNPACK_CANONICAL_shift + 3)) == 1) B_f += B_f; else B_f <<= ((_FP_UNPACK_CANONICAL_shift + 3)); } while (0); B_e -= (127 - 1 + _FP_UNPACK_CANONICAL_shift); B_c = 0; _fex |= (0); } break; case 255: if ((B_f == 0)) B_c = 2; else { B_c = 3; if (((0) ? ((B_f) & ((unsigned long) 1 << (24 -2))) : !((B_f) & ((unsigned long) 1 << (24 -2))))) _fex |= (0 | 0); } break; } } while (0); } while (0);
  do { do { union _FP_UNION_S _FP_UNPACK_RAW_1_flo; _FP_UNPACK_RAW_1_flo.flt = ((c)); C_f = _FP_UNPACK_RAW_1_flo.bits.frac; C_e = _FP_UNPACK_RAW_1_flo.bits.exp; C_s = _FP_UNPACK_RAW_1_flo.bits.sign; } while (0); do { switch (C_e) { default: (C_f) |= ((unsigned long) 1 << (24 -1)); do { if (__builtin_constant_p (3) && (3) == 1) C_f += C_f; else C_f <<= (3); } while (0); C_e -= 127; C_c = 0; break; case 0: if ((C_f == 0)) C_c = 1; else if (0) { C_c = 1; (C_f = 0); _fex |= (0); } else { long _FP_UNPACK_CANONICAL_shift; do { _Static_assert (((sizeof (unsigned long) == sizeof (unsigned int) || (sizeof (unsigned long) == sizeof (unsigned long)) || (sizeof (unsigned long) == sizeof (unsigned long long)))), "_FP_W_TYPE size unsupported for clz"); if (sizeof (unsigned long) == sizeof (unsigned int)) ((_FP_UNPACK_CANONICAL_shift)) = __builtin_clz (C_f); else if (sizeof (unsigned long) == sizeof (unsigned long)) ((_FP_UNPACK_CANONICAL_shift)) = __builtin_clzl (C_f); else ((_FP_UNPACK_CANONICAL_shift)) = __builtin_clzll (C_f); } while (0); _FP_UNPACK_CANONICAL_shift -= (32 - 24); do { if (__builtin_constant_p ((_FP_UNPACK_CANONICAL_shift + 3)) && ((_FP_UNPACK_CANONICAL_shift + 3)) == 1) C_f += C_f; else C_f <<= ((_FP_UNPACK_CANONICAL_shift + 3)); } while (0); C_e -= (127 - 1 + _FP_UNPACK_CANONICAL_shift); C_c = 0; _fex |= (0); } break; case 255: if ((C_f == 0)) C_c = 2; else { C_c = 3; if (((0) ? ((C_f) & ((unsigned long) 1 << (24 -2))) : !((C_f) & ((unsigned long) 1 << (24 -2))))) _fex |= (0 | 0); } break; } } while (0); } while (0);
  do { __label__ done_fma; long _FP_FMA_T_c __attribute__ ((unused)) ; long _FP_FMA_T_s __attribute__ ((unused)) ; long _FP_FMA_T_e __attribute__ ((unused)) ; unsigned long _FP_FMA_T_f ; _FP_FMA_T_s = A_s ^ B_s; _FP_FMA_T_e = A_e + B_e + 1; switch ((((A_c) << 2) | (B_c))) { case (((0) << 2) | (0)): switch (C_c) { case 2: case 3: R_s = C_s; (R_f = C_f); R_c = C_c; break; case 1: R_c = 0; R_s = _FP_FMA_T_s; R_e = _FP_FMA_T_e; do { unsigned long _FP_MUL_MEAT_1_wide_Z_f0 , _FP_MUL_MEAT_1_wide_Z_f1 ; do { do { unsigned long __x0, __x1, __x2, __x3; UHWtype __ul, __vl, __uh, __vh; __ul = ((unsigned long) (A_f) & (((unsigned long) 1 << (32 / 2)) - 1)); __uh = ((unsigned long) (A_f) >> (32 / 2)); __vl = ((unsigned long) (B_f) & (((unsigned long) 1 << (32 / 2)) - 1)); __vh = ((unsigned long) (B_f) >> (32 / 2)); __x0 = (unsigned long) __ul * __vl; __x1 = (unsigned long) __ul * __vh; __x2 = (unsigned long) __uh * __vl; __x3 = (unsigned long) __uh * __vh; __x1 += ((unsigned long) (__x0) >> (32 / 2)); __x1 += __x2; if (__x1 < __x2) __x3 += ((unsigned long) 1 << (32 / 2)); (_FP_MUL_MEAT_1_wide_Z_f1) = __x3 + ((unsigned long) (__x1) >> (32 / 2)); (_FP_MUL_MEAT_1_wide_Z_f0) = ((unsigned long) (__x1) & (((unsigned long) 1 << (32 / 2)) - 1)) * ((unsigned long) 1 << (32 / 2)) + ((unsigned long) (__x0) & (((unsigned long) 1 << (32 / 2)) - 1)); } while (0); } while (0); (void) (((((3 + 24))-1) < 32) ? ({ _FP_MUL_MEAT_1_wide_Z_f0 = (_FP_MUL_MEAT_1_wide_Z_f1 << (32 - (((3 + 24))-1)) | _FP_MUL_MEAT_1_wide_Z_f0 >> (((3 + 24))-1) | (__builtin_constant_p (((3 + 24))-1) && (((3 + 24))-1) == 1 ? _FP_MUL_MEAT_1_wide_Z_f0 & 1 : (_FP_MUL_MEAT_1_wide_Z_f0 << (32 - (((3 + 24))-1))) != 0)); _FP_MUL_MEAT_1_wide_Z_f1 >>= (((3 + 24))-1); }) : ({ _FP_MUL_MEAT_1_wide_Z_f0 = (_FP_MUL_MEAT_1_wide_Z_f1 >> ((((3 + 24))-1) - 32) | ((((((3 + 24))-1) == 32 ? 0 : (_FP_MUL_MEAT_1_wide_Z_f1 << (2*32 - (((3 + 24))-1)))) | _FP_MUL_MEAT_1_wide_Z_f0) != 0)); _FP_MUL_MEAT_1_wide_Z_f1 = 0; })); R_f = _FP_MUL_MEAT_1_wide_Z_f0; } while (0); if ((R_f & ((unsigned long) 1 << ((3 + 24))))) (R_f = (R_f >> ((1)) | (__builtin_constant_p ((1)) && ((1)) == 1 ? R_f & 1 : (R_f << (32 - ((1)))) != 0))); else R_e--; break; case 0:; unsigned long _FP_FMA_TD_f0 , _FP_FMA_TD_f1 ; unsigned long _FP_FMA_ZD_f0 , _FP_FMA_ZD_f1 ; unsigned long _FP_FMA_RD_f0 , _FP_FMA_RD_f1 ; do { do { unsigned long __x0, __x1, __x2, __x3; UHWtype __ul, __vl, __uh, __vh; __ul = ((unsigned long) (A_f) & (((unsigned long) 1 << (32 / 2)) - 1)); __uh = ((unsigned long) (A_f) >> (32 / 2)); __vl = ((unsigned long) (B_f) & (((unsigned long) 1 << (32 / 2)) - 1)); __vh = ((unsigned long) (B_f) >> (32 / 2)); __x0 = (unsigned long) __ul * __vl; __x1 = (unsigned long) __ul * __vh; __x2 = (unsigned long) __uh * __vl; __x3 = (unsigned long) __uh * __vh; __x1 += ((unsigned long) (__x0) >> (32 / 2)); __x1 += __x2; if (__x1 < __x2) __x3 += ((unsigned long) 1 << (32 / 2)); (_FP_FMA_TD_f1) = __x3 + ((unsigned long) (__x1) >> (32 / 2)); (_FP_FMA_TD_f0) = ((unsigned long) (__x1) & (((unsigned long) 1 << (32 / 2)) - 1)) * ((unsigned long) 1 << (32 / 2)) + ((unsigned long) (__x0) & (((unsigned long) 1 << (32 / 2)) - 1)); } while (0); } while (0); R_e = _FP_FMA_T_e; int _FP_FMA_tsh = ((_FP_FMA_TD_f1) & ((unsigned long) 1 << ((2 * (3 + 24)) - 1) % 32)) == 0; _FP_FMA_T_e -= _FP_FMA_tsh; int _FP_FMA_ediff = _FP_FMA_T_e - C_e; if (_FP_FMA_ediff >= 0) { int _FP_FMA_shift = (3 + 24) - _FP_FMA_tsh - _FP_FMA_ediff; if (_FP_FMA_shift <= -(3 + 24)) (_FP_FMA_ZD_f0 = 1, _FP_FMA_ZD_f1 = 0); else { ((_FP_FMA_ZD_f0 = C_f), (_FP_FMA_ZD_f1 = 0)); if (_FP_FMA_shift < 0) (void) (((-_FP_FMA_shift) < 32) ? ({ _FP_FMA_ZD_f0 = (_FP_FMA_ZD_f1 << (32 - (-_FP_FMA_shift)) | _FP_FMA_ZD_f0 >> (-_FP_FMA_shift) | (__builtin_constant_p (-_FP_FMA_shift) && (-_FP_FMA_shift) == 1 ? _FP_FMA_ZD_f0 & 1 : (_FP_FMA_ZD_f0 << (32 - (-_FP_FMA_shift))) != 0)); _FP_FMA_ZD_f1 >>= (-_FP_FMA_shift); }) : ({ _FP_FMA_ZD_f0 = (_FP_FMA_ZD_f1 >> ((-_FP_FMA_shift) - 32) | ((((-_FP_FMA_shift) == 32 ? 0 : (_FP_FMA_ZD_f1 << (2*32 - (-_FP_FMA_shift)))) | _FP_FMA_ZD_f0) != 0)); _FP_FMA_ZD_f1 = 0; })); else if (_FP_FMA_shift > 0) (void) (((_FP_FMA_shift) < 32) ? ({ if (__builtin_constant_p (_FP_FMA_shift) && (_FP_FMA_shift) == 1) { _FP_FMA_ZD_f1 = _FP_FMA_ZD_f1 + _FP_FMA_ZD_f1 + (((signed long) (_FP_FMA_ZD_f0)) < 0); _FP_FMA_ZD_f0 += _FP_FMA_ZD_f0; } else { _FP_FMA_ZD_f1 = _FP_FMA_ZD_f1 << (_FP_FMA_shift) | _FP_FMA_ZD_f0 >> (32 - (_FP_FMA_shift)); _FP_FMA_ZD_f0 <<= (_FP_FMA_shift); } 0; }) : ({ _FP_FMA_ZD_f1 = _FP_FMA_ZD_f0 << ((_FP_FMA_shift) - 32); _FP_FMA_ZD_f0 = 0; })); } R_s = _FP_FMA_T_s; if (_FP_FMA_T_s == C_s) do { unsigned long __x; __x = (_FP_FMA_TD_f0) + (_FP_FMA_ZD_f0); (_FP_FMA_RD_f1) = (_FP_FMA_TD_f1) + (_FP_FMA_ZD_f1) + (__x < (_FP_FMA_TD_f0)); (_FP_FMA_RD_f0) = __x; } while (0); else { do { unsigned long __x; __x = (_FP_FMA_TD_f0) - (_FP_FMA_ZD_f0); (_FP_FMA_RD_f1) = (_FP_FMA_TD_f1) - (_FP_FMA_ZD_f1) - (__x > (_FP_FMA_TD_f0)); (_FP_FMA_RD_f0) = __x; } while (0); if (((signed long) _FP_FMA_RD_f1 < 0)) { R_s = C_s; do { unsigned long __x; __x = (_FP_FMA_ZD_f0) - (_FP_FMA_TD_f0); (_FP_FMA_RD_f1) = (_FP_FMA_ZD_f1) - (_FP_FMA_TD_f1) - (__x > (_FP_FMA_ZD_f0)); (_FP_FMA_RD_f0) = __x; } while (0); } } } else { R_e = C_e; R_s = C_s; ((_FP_FMA_ZD_f0 = C_f), (_FP_FMA_ZD_f1 = 0)); (void) ((((3 + 24)) < 32) ? ({ if (__builtin_constant_p ((3 + 24)) && ((3 + 24)) == 1) { _FP_FMA_ZD_f1 = _FP_FMA_ZD_f1 + _FP_FMA_ZD_f1 + (((signed long) (_FP_FMA_ZD_f0)) < 0); _FP_FMA_ZD_f0 += _FP_FMA_ZD_f0; } else { _FP_FMA_ZD_f1 = _FP_FMA_ZD_f1 << ((3 + 24)) | _FP_FMA_ZD_f0 >> (32 - ((3 + 24))); _FP_FMA_ZD_f0 <<= ((3 + 24)); } 0; }) : ({ _FP_FMA_ZD_f1 = _FP_FMA_ZD_f0 << (((3 + 24)) - 32); _FP_FMA_ZD_f0 = 0; })); int _FP_FMA_shift = -_FP_FMA_ediff - _FP_FMA_tsh; if (_FP_FMA_shift >= (2 * (3 + 24))) (_FP_FMA_TD_f0 = 1, _FP_FMA_TD_f1 = 0); else if (_FP_FMA_shift > 0) (void) (((_FP_FMA_shift) < 32) ? ({ _FP_FMA_TD_f0 = (_FP_FMA_TD_f1 << (32 - (_FP_FMA_shift)) | _FP_FMA_TD_f0 >> (_FP_FMA_shift) | (__builtin_constant_p (_FP_FMA_shift) && (_FP_FMA_shift) == 1 ? _FP_FMA_TD_f0 & 1 : (_FP_FMA_TD_f0 << (32 - (_FP_FMA_shift))) != 0)); _FP_FMA_TD_f1 >>= (_FP_FMA_shift); }) : ({ _FP_FMA_TD_f0 = (_FP_FMA_TD_f1 >> ((_FP_FMA_shift) - 32) | ((((_FP_FMA_shift) == 32 ? 0 : (_FP_FMA_TD_f1 << (2*32 - (_FP_FMA_shift)))) | _FP_FMA_TD_f0) != 0)); _FP_FMA_TD_f1 = 0; })); if (C_s == _FP_FMA_T_s) do { unsigned long __x; __x = (_FP_FMA_ZD_f0) + (_FP_FMA_TD_f0); (_FP_FMA_RD_f1) = (_FP_FMA_ZD_f1) + (_FP_FMA_TD_f1) + (__x < (_FP_FMA_ZD_f0)); (_FP_FMA_RD_f0) = __x; } while (0); else do { unsigned long __x; __x = (_FP_FMA_ZD_f0) - (_FP_FMA_TD_f0); (_FP_FMA_RD_f1) = (_FP_FMA_ZD_f1) - (_FP_FMA_TD_f1) - (__x > (_FP_FMA_ZD_f0)); (_FP_FMA_RD_f0) = __x; } while (0); } if (((_FP_FMA_RD_f1 | _FP_FMA_RD_f0) == 0)) { if (_FP_FMA_T_s == C_s) R_s = C_s; else R_s = (0 == 3); (R_f = 0); R_c = 1; } else { int _FP_FMA_rlz; do { if (_FP_FMA_RD_f1) do { _Static_assert (((sizeof (unsigned long) == sizeof (unsigned int) || (sizeof (unsigned long) == sizeof (unsigned long)) || (sizeof (unsigned long) == sizeof (unsigned long long)))), "_FP_W_TYPE size unsupported for clz"); if (sizeof (unsigned long) == sizeof (unsigned int)) ((_FP_FMA_rlz)) = __builtin_clz (_FP_FMA_RD_f1); else if (sizeof (unsigned long) == sizeof (unsigned long)) ((_FP_FMA_rlz)) = __builtin_clzl (_FP_FMA_RD_f1); else ((_FP_FMA_rlz)) = __builtin_clzll (_FP_FMA_RD_f1); } while (0); else { do { _Static_assert (((sizeof (unsigned long) == sizeof (unsigned int) || (sizeof (unsigned long) == sizeof (unsigned long)) || (sizeof (unsigned long) == sizeof (unsigned long long)))), "_FP_W_TYPE size unsupported for clz"); if (sizeof (unsigned long) == sizeof (unsigned int)) ((_FP_FMA_rlz)) = __builtin_clz (_FP_FMA_RD_f0); else if (sizeof (unsigned long) == sizeof (unsigned long)) ((_FP_FMA_rlz)) = __builtin_clzl (_FP_FMA_RD_f0); else ((_FP_FMA_rlz)) = __builtin_clzll (_FP_FMA_RD_f0); } while (0); (_FP_FMA_rlz) += 32; } } while (0); _FP_FMA_rlz -= ((2 * 32) - (2 * (3 + 24))); R_e -= _FP_FMA_rlz; int _FP_FMA_shift = (3 + 24) - _FP_FMA_rlz; if (_FP_FMA_shift > 0) (void) (((_FP_FMA_shift) < 32) ? ({ _FP_FMA_RD_f0 = (_FP_FMA_RD_f1 << (32 - (_FP_FMA_shift)) | _FP_FMA_RD_f0 >> (_FP_FMA_shift) | (__builtin_constant_p (_FP_FMA_shift) && (_FP_FMA_shift) == 1 ? _FP_FMA_RD_f0 & 1 : (_FP_FMA_RD_f0 << (32 - (_FP_FMA_shift))) != 0)); _FP_FMA_RD_f1 >>= (_FP_FMA_shift); }) : ({ _FP_FMA_RD_f0 = (_FP_FMA_RD_f1 >> ((_FP_FMA_shift) - 32) | ((((_FP_FMA_shift) == 32 ? 0 : (_FP_FMA_RD_f1 << (2*32 - (_FP_FMA_shift)))) | _FP_FMA_RD_f0) != 0)); _FP_FMA_RD_f1 = 0; })); else if (_FP_FMA_shift < 0) (void) (((-_FP_FMA_shift) < 32) ? ({ if (__builtin_constant_p (-_FP_FMA_shift) && (-_FP_FMA_shift) == 1) { _FP_FMA_RD_f1 = _FP_FMA_RD_f1 + _FP_FMA_RD_f1 + (((signed long) (_FP_FMA_RD_f0)) < 0); _FP_FMA_RD_f0 += _FP_FMA_RD_f0; } else { _FP_FMA_RD_f1 = _FP_FMA_RD_f1 << (-_FP_FMA_shift) | _FP_FMA_RD_f0 >> (32 - (-_FP_FMA_shift)); _FP_FMA_RD_f0 <<= (-_FP_FMA_shift); } 0; }) : ({ _FP_FMA_RD_f1 = _FP_FMA_RD_f0 << ((-_FP_FMA_shift) - 32); _FP_FMA_RD_f0 = 0; })); (R_f = _FP_FMA_RD_f0); R_c = 0; } break; } goto done_fma; case (((3) << 2) | (3)): do { if (((A_f) & ((unsigned long) 1 << (24 -2))) && !((B_f) & ((unsigned long) 1 << (24 -2)))) { _FP_FMA_T_s = B_s; (_FP_FMA_T_f = B_f); } else { _FP_FMA_T_s = A_s; (_FP_FMA_T_f = A_f); } _FP_FMA_T_c = 3; } while (0); break; case (((3) << 2) | (0)): case (((3) << 2) | (2)): case (((3) << 2) | (1)): _FP_FMA_T_s = A_s; case (((2) << 2) | (2)): case (((2) << 2) | (0)): case (((1) << 2) | (0)): case (((1) << 2) | (1)): (_FP_FMA_T_f = A_f); _FP_FMA_T_c = A_c; break; case (((0) << 2) | (3)): case (((2) << 2) | (3)): case (((1) << 2) | (3)): _FP_FMA_T_s = B_s; case (((0) << 2) | (2)): case (((0) << 2) | (1)): (_FP_FMA_T_f = B_f); _FP_FMA_T_c = B_c; break; case (((2) << 2) | (1)): case (((1) << 2) | (2)): _FP_FMA_T_s = 0; _FP_FMA_T_c = 3; (_FP_FMA_T_f = ((((unsigned long) 1 << (24 -2)) << 1) - 1)); _fex |= (0 | 0); break; default: __builtin_unreachable (); } switch ((((_FP_FMA_T_c) << 2) | (C_c))) { case (((3) << 2) | (3)): do { if (((_FP_FMA_T_f) & ((unsigned long) 1 << (24 -2))) && !((C_f) & ((unsigned long) 1 << (24 -2)))) { R_s = C_s; (R_f = C_f); } else { R_s = _FP_FMA_T_s; (R_f = _FP_FMA_T_f); } R_c = 3; } while (0); break; case (((3) << 2) | (0)): case (((3) << 2) | (2)): case (((3) << 2) | (1)): case (((2) << 2) | (0)): case (((2) << 2) | (1)): R_s = _FP_FMA_T_s; (R_f = _FP_FMA_T_f); R_c = _FP_FMA_T_c; break; case (((2) << 2) | (3)): case (((1) << 2) | (3)): case (((1) << 2) | (0)): case (((1) << 2) | (2)): R_s = C_s; (R_f = C_f); R_c = C_c; R_e = C_e; break; case (((2) << 2) | (2)): if (_FP_FMA_T_s == C_s) { R_s = C_s; (R_f = C_f); R_c = C_c; } else { R_s = 0; R_c = 3; (R_f = ((((unsigned long) 1 << (24 -2)) << 1) - 1)); _fex |= (0 | 0); } break; case (((1) << 2) | (1)): if (_FP_FMA_T_s == C_s) R_s = C_s; else R_s = (0 == 3); (R_f = C_f); R_c = C_c; break; default: __builtin_unreachable (); } done_fma: ; } while (0);
  do { do { switch (R_c) { case 0: R_e += 127; if (R_e > 0) { do { if ((R_f) & 7) { _fex |= (0); switch (0) { case 0: do { if (((R_f) & 15) != ((unsigned long) 1 << 2)) (R_f += ((unsigned long) 1 << 2)); } while (0); break; case 1: (void) 0; break; case 2: do { if (!R_s && ((R_f) & 7)) (R_f += ((unsigned long) 1 << 3)); } while (0); break; case 3: do { if (R_s && ((R_f) & 7)) (R_f += ((unsigned long) 1 << 3)); } while (0); break; } } } while (0); if ((R_f & ((unsigned long) 1 << ((3 + 24))))) { (R_f &= ~((unsigned long) 1 << ((3 + 24)))); R_e++; } (R_f >>= 3); if (R_e >= 255) { switch (0) { case 0: R_c = 2; break; case 2: if (!R_s) R_c = 2; break; case 3: if (R_s) R_c = 2; break; } if (R_c == 2) { R_e = 255; (R_f = 0); } else { R_e = 255 - 1; (R_f = (~(signed long) 0)); } _fex |= (0); _fex |= (0); } } else { int _FP_PACK_CANONICAL_is_tiny = 1; if (0 && R_e == 0) { long _FP_PACK_CANONICAL_T_c __attribute__ ((unused)) ; long _FP_PACK_CANONICAL_T_s __attribute__ ((unused)) ; long _FP_PACK_CANONICAL_T_e __attribute__ ((unused)) ; unsigned long _FP_PACK_CANONICAL_T_f ; (_FP_PACK_CANONICAL_T_f = R_f); _FP_PACK_CANONICAL_T_s = R_s; _FP_PACK_CANONICAL_T_e = R_e; do { if ((_FP_PACK_CANONICAL_T_f) & 7) { _fex |= (0); switch (0) { case 0: do { if (((_FP_PACK_CANONICAL_T_f) & 15) != ((unsigned long) 1 << 2)) (_FP_PACK_CANONICAL_T_f += ((unsigned long) 1 << 2)); } while (0); break; case 1: (void) 0; break; case 2: do { if (!_FP_PACK_CANONICAL_T_s && ((_FP_PACK_CANONICAL_T_f) & 7)) (_FP_PACK_CANONICAL_T_f += ((unsigned long) 1 << 3)); } while (0); break; case 3: do { if (_FP_PACK_CANONICAL_T_s && ((_FP_PACK_CANONICAL_T_f) & 7)) (_FP_PACK_CANONICAL_T_f += ((unsigned long) 1 << 3)); } while (0); break; } } } while (0); if ((_FP_PACK_CANONICAL_T_f & ((unsigned long) 1 << ((3 + 24))))) _FP_PACK_CANONICAL_is_tiny = 0; } R_e = -R_e + 1; if (R_e <= (3 + 24)) { (R_f = (R_f >> ((R_e)) | (__builtin_constant_p ((R_e)) && ((R_e)) == 1 ? R_f & 1 : (R_f << (32 - ((R_e)))) != 0))); do { if ((R_f) & 7) { _fex |= (0); switch (0) { case 0: do { if (((R_f) & 15) != ((unsigned long) 1 << 2)) (R_f += ((unsigned long) 1 << 2)); } while (0); break; case 1: (void) 0; break; case 2: do { if (!R_s && ((R_f) & 7)) (R_f += ((unsigned long) 1 << 3)); } while (0); break; case 3: do { if (R_s && ((R_f) & 7)) (R_f += ((unsigned long) 1 << 3)); } while (0); break; } } } while (0); if ((R_f) & (((unsigned long) 1 << ((3 + 24))) >> 1)) { R_e = 1; (R_f = 0); _fex |= (0); } else { R_e = 0; (R_f >>= 3); } if (_FP_PACK_CANONICAL_is_tiny && (((_fex) & 0) || (0 & 0))) _fex |= (0); } else { R_e = 0; if (!(R_f == 0)) { (R_f = 1); do { if ((R_f) & 7) { _fex |= (0); switch (0) { case 0: do { if (((R_f) & 15) != ((unsigned long) 1 << 2)) (R_f += ((unsigned long) 1 << 2)); } while (0); break; case 1: (void) 0; break; case 2: do { if (!R_s && ((R_f) & 7)) (R_f += ((unsigned long) 1 << 3)); } while (0); break; case 3: do { if (R_s && ((R_f) & 7)) (R_f += ((unsigned long) 1 << 3)); } while (0); break; } } } while (0); (R_f) >>= (3); } _fex |= (0); } } break; case 1: R_e = 0; (R_f = 0); break; case 2: R_e = 255; (R_f = 0); break; case 3: R_e = 255; if (!1) { (R_f = ((((unsigned long) 1 << (24 -2)) << 1) - 1)); R_s = 0; } else do { if (0) { (R_f) &= ((unsigned long) 1 << (24 -2)) - 1; if ((R_f == 0)) { R_s = 0; (R_f = ((((unsigned long) 1 << (24 -2)) << 1) - 1)); } } else (R_f) |= ((unsigned long) 1 << (24 -2)); } while (0); break; } } while (0); do { union _FP_UNION_S _FP_PACK_RAW_1_flo; _FP_PACK_RAW_1_flo.bits.frac = R_f; _FP_PACK_RAW_1_flo.bits.exp = R_e; _FP_PACK_RAW_1_flo.bits.sign = R_s; ((r)) = _FP_PACK_RAW_1_flo.flt; } while (0); } while (0);
  do {} while (0);

  return r;
}

# 65 "../sysdeps/ieee754/soft-fp/s_fmaf.c"
#pragma GCC diagnostic pop
# 65 "../sysdeps/ieee754/soft-fp/s_fmaf.c"
;


extern __typeof (__fmaf) fmaf __attribute__ ((weak, alias ("__fmaf"))) __attribute__ ((__copy__ (__fmaf)));; extern __typeof (__fmaf) fmaf32 __attribute__ ((weak, alias ("__fmaf"))) __attribute__ ((__copy__ (__fmaf)));
Martin Sebor Sept. 18, 2021, 6:46 p.m. UTC | #4
On 9/17/21 10:08 PM, Jeff Law wrote:
> 
> 
> On 9/17/2021 4:05 PM, Martin Sebor wrote:
>> On 9/2/21 10:28 AM, Jeff Law via Gcc-patches wrote:
>>>
>>>
>>> On 8/30/2021 2:03 PM, Martin Sebor via Gcc-patches wrote:
>>>> The predicate analysis subset of the tree-ssa-uninit pass isn't
>>>> necessarily specific to the detection of uninitialized reads.
>>>> Suitably parameterized, the same core logic could be used in
>>>> other warning passes to improve their S/N ratio, or issue more
>>>> nuanced diagnostics (e.g., when an invalid access cannot be
>>>> ruled out but also need not in reality be unavoidable, issue
>>>> a "may be invalid" type of warning rather than "is invalid").
>>>>
>>>> Separating the predicate analysis logic from the uninitialized
>>>> pass and exposing a narrow API should also make it easier to
>>>> understand and evolve each part independently of the other,
>>>> or replace one with a better implementation without modifying
>>>> the other.(*)
>>>>
>>>> As the first step in this direction, the attached patch extracts
>>>> the predicate analysis logic out of the pass, turns the interface
>>>> into public class members, and hides the internals in either
>>>> private members or static functions defined in a new source file.
>>>> (**)
>>>>
>>>> The changes should have no externally observable effect (i.e.,
>>>> should cause no changes in warnings), except on the contents of
>>>> the uninitialized dump.  While making the changes I enhanced
>>>> the dumps to help me follow the logic.  Turning some previously
>>>> free-standing functions into members involved changing their
>>>> signatures and adjusting their callers.  While making these
>>>> changes I also renamed some of them as well some variables for
>>>> improved clarity.  Finally, I moved declarations of locals
>>>> closer to their point of initialization.
>>>>
>>>> Tested on x86_64-linux.  Besides the usual bootstrap/regtest
>>>> I also tentatively verified the generality of the new class
>>>> interfaces by making use of it in -Warray-bounds.  Besides there,
>>>> I'd like to make use of it in the new gimple-ssa-warn-access pass
>>>> and, longer term, any other flow-sensitive warnings that might
>>>> benefit from it.
>>>>
>>>> Martin
>>>>
>>>> [*] A review of open -Wuninitialized bugs I did while working
>>>> on this project made me aware of a number of opportunities to
>>>> improve the analyzer to reduce the number of false positives
>>>> -Wmaybe-uninitiailzed suffers from.
>>>>
>>>> [**] The class isn't fully general and, like the uninit pass,
>>>> only works with PHI nodes.  I plan to generalize it to compute
>>>> the set of predicates between any two basic blocks.
>>>>
>>>> gcc-predanal.diff
>>>>
>>>> Factor predidacte analysis out of tree-ssa-uninit.c into its own 
>>>> module.
>>>>
>>>> gcc/ChangeLog:
>>>>
>>>>     * Makefile.in (OBJS): Add gimple-predicate-analysis.o.
>>>>     * tree-ssa-uninit.c (max_phi_args): Move to 
>>>> gimple-predicate-analysis.
>>>>     (MASK_SET_BIT, MASK_TEST_BIT, MASK_EMPTY): Same.
>>>>     (check_defs):
>>>>     (can_skip_redundant_opnd):
>>>>     (compute_uninit_opnds_pos): Adjust to namespace change.
>>>>     (find_pdom): Move to gimple-predicate-analysis.cc.
>>>>     (find_dom): Same.
>>>>     (struct uninit_undef_val_t): New.
>>>>     (is_non_loop_exit_postdominating): Move to 
>>>> gimple-predicate-analysis.cc.
>>>>     (find_control_equiv_block): Same.
>>>>     (MAX_NUM_CHAINS, MAX_CHAIN_LEN, MAX_POSTDOM_CHECK): Same.
>>>>     (MAX_SWITCH_CASES): Same.
>>>>     (compute_control_dep_chain): Same.
>>>>     (find_uninit_use): Use predicate analyzer.
>>>>     (struct pred_info): Move to gimple-predicate-analysis.
>>>>     (convert_control_dep_chain_into_preds): Same.
>>>>     (find_predicates): Same.
>>>>     (collect_phi_def_edges): Same.
>>>>     (warn_uninitialized_phi): Use predicate analyzer.
>>>>     (find_def_preds): Move to gimple-predicate-analysis.
>>>>     (dump_pred_info): Same.
>>>>     (dump_pred_chain): Same.
>>>>     (dump_predicates): Same.
>>>>     (destroy_predicate_vecs): Remove.
>>>>     (execute_late_warn_uninitialized): New.
>>>>     (get_cmp_code): Move to gimple-predicate-analysis.
>>>>     (is_value_included_in): Same.
>>>>     (value_sat_pred_p): Same.
>>>>     (find_matching_predicate_in_rest_chains): Same.
>>>>     (is_use_properly_guarded): Same.
>>>>     (prune_uninit_phi_opnds): Same.
>>>>     (find_var_cmp_const): Same.
>>>>     (use_pred_not_overlap_with_undef_path_pred): Same.
>>>>     (pred_equal_p): Same.
>>>>     (is_neq_relop_p): Same.
>>>>     (is_neq_zero_form_p): Same.
>>>>     (pred_expr_equal_p): Same.
>>>>     (is_pred_expr_subset_of): Same.
>>>>     (is_pred_chain_subset_of): Same.
>>>>     (is_included_in): Same.
>>>>     (is_superset_of): Same.
>>>>     (pred_neg_p): Same.
>>>>     (simplify_pred): Same.
>>>>     (simplify_preds_2): Same.
>>>>     (simplify_preds_3): Same.
>>>>     (simplify_preds_4): Same.
>>>>     (simplify_preds): Same.
>>>>     (push_pred): Same.
>>>>     (push_to_worklist): Same.
>>>>     (get_pred_info_from_cmp): Same.
>>>>     (is_degenerated_phi): Same.
>>>>     (normalize_one_pred_1): Same.
>>>>     (normalize_one_pred): Same.
>>>>     (normalize_one_pred_chain): Same.
>>>>     (normalize_preds): Same.
>>>>     (can_one_predicate_be_invalidated_p): Same.
>>>>     (can_chain_union_be_invalidated_p): Same.
>>>>     (uninit_uses_cannot_happen): Same.
>>>>     (pass_late_warn_uninitialized::execute): Define.
>>>>     * gimple-predicate-analysis.cc: New file.
>>>>     * gimple-predicate-analysis.h: New file.
>>> Thanks for tackling this.  It's something I think we've needed for a 
>>> long time.
>>>
>>> I've only done a cursory review since this is primarily moving the 
>>> analysis engine to its own file and class-ifying it.
>>>
>>> As we build additional consumers I won't be surprised if we have to 
>>> adjust the exposed class API, but that's fine.   The first goal is to 
>>> get the analysis disentangled from the consumer(s).
>>>
>>> OK.  Looking forward to seeing the analysis used elsewhere.
>>
>> Thanks, I just pushed it.
>>
>> As a heads up, I've been having some weird email problems lately and
>> didn't find your approval until today, in my Trash folder.  Just in
>> case there's fallout that I'm not responsive to, please either ping
>> me on IRC or email my @redhat account.
> Weird.  I wonder if google is trying to tell me something :-)
> 
> Anyway,  it does seem to be triggering an ICE on nios2-linux-gnu and 
> csky-linux-gnu (so far).
> 
> Compile the attached code with -O2 -Wall  with a nios2-linux-gnu cross 
> compiler.  You should get an ICE in the predicate bits.

Thanks.  An assert I added to help me debug the code is firing.
Let me see if it's the assert that's wrong or if I messed up
something else.

Martin
Martin Sebor Sept. 18, 2021, 9:14 p.m. UTC | #5
On 9/18/21 12:46 PM, Martin Sebor wrote:
> On 9/17/21 10:08 PM, Jeff Law wrote:
>>
>>
>> On 9/17/2021 4:05 PM, Martin Sebor wrote:
>>> On 9/2/21 10:28 AM, Jeff Law via Gcc-patches wrote:
>>>>
>>>>
>>>> On 8/30/2021 2:03 PM, Martin Sebor via Gcc-patches wrote:
>>>>> The predicate analysis subset of the tree-ssa-uninit pass isn't
>>>>> necessarily specific to the detection of uninitialized reads.
>>>>> Suitably parameterized, the same core logic could be used in
>>>>> other warning passes to improve their S/N ratio, or issue more
>>>>> nuanced diagnostics (e.g., when an invalid access cannot be
>>>>> ruled out but also need not in reality be unavoidable, issue
>>>>> a "may be invalid" type of warning rather than "is invalid").
>>>>>
>>>>> Separating the predicate analysis logic from the uninitialized
>>>>> pass and exposing a narrow API should also make it easier to
>>>>> understand and evolve each part independently of the other,
>>>>> or replace one with a better implementation without modifying
>>>>> the other.(*)
>>>>>
>>>>> As the first step in this direction, the attached patch extracts
>>>>> the predicate analysis logic out of the pass, turns the interface
>>>>> into public class members, and hides the internals in either
>>>>> private members or static functions defined in a new source file.
>>>>> (**)
>>>>>
>>>>> The changes should have no externally observable effect (i.e.,
>>>>> should cause no changes in warnings), except on the contents of
>>>>> the uninitialized dump.  While making the changes I enhanced
>>>>> the dumps to help me follow the logic.  Turning some previously
>>>>> free-standing functions into members involved changing their
>>>>> signatures and adjusting their callers.  While making these
>>>>> changes I also renamed some of them as well some variables for
>>>>> improved clarity.  Finally, I moved declarations of locals
>>>>> closer to their point of initialization.
>>>>>
>>>>> Tested on x86_64-linux.  Besides the usual bootstrap/regtest
>>>>> I also tentatively verified the generality of the new class
>>>>> interfaces by making use of it in -Warray-bounds.  Besides there,
>>>>> I'd like to make use of it in the new gimple-ssa-warn-access pass
>>>>> and, longer term, any other flow-sensitive warnings that might
>>>>> benefit from it.
>>>>>
>>>>> Martin
>>>>>
>>>>> [*] A review of open -Wuninitialized bugs I did while working
>>>>> on this project made me aware of a number of opportunities to
>>>>> improve the analyzer to reduce the number of false positives
>>>>> -Wmaybe-uninitiailzed suffers from.
>>>>>
>>>>> [**] The class isn't fully general and, like the uninit pass,
>>>>> only works with PHI nodes.  I plan to generalize it to compute
>>>>> the set of predicates between any two basic blocks.
>>>>>
>>>>> gcc-predanal.diff
>>>>>
>>>>> Factor predidacte analysis out of tree-ssa-uninit.c into its own 
>>>>> module.
>>>>>
>>>>> gcc/ChangeLog:
>>>>>
>>>>>     * Makefile.in (OBJS): Add gimple-predicate-analysis.o.
>>>>>     * tree-ssa-uninit.c (max_phi_args): Move to 
>>>>> gimple-predicate-analysis.
>>>>>     (MASK_SET_BIT, MASK_TEST_BIT, MASK_EMPTY): Same.
>>>>>     (check_defs):
>>>>>     (can_skip_redundant_opnd):
>>>>>     (compute_uninit_opnds_pos): Adjust to namespace change.
>>>>>     (find_pdom): Move to gimple-predicate-analysis.cc.
>>>>>     (find_dom): Same.
>>>>>     (struct uninit_undef_val_t): New.
>>>>>     (is_non_loop_exit_postdominating): Move to 
>>>>> gimple-predicate-analysis.cc.
>>>>>     (find_control_equiv_block): Same.
>>>>>     (MAX_NUM_CHAINS, MAX_CHAIN_LEN, MAX_POSTDOM_CHECK): Same.
>>>>>     (MAX_SWITCH_CASES): Same.
>>>>>     (compute_control_dep_chain): Same.
>>>>>     (find_uninit_use): Use predicate analyzer.
>>>>>     (struct pred_info): Move to gimple-predicate-analysis.
>>>>>     (convert_control_dep_chain_into_preds): Same.
>>>>>     (find_predicates): Same.
>>>>>     (collect_phi_def_edges): Same.
>>>>>     (warn_uninitialized_phi): Use predicate analyzer.
>>>>>     (find_def_preds): Move to gimple-predicate-analysis.
>>>>>     (dump_pred_info): Same.
>>>>>     (dump_pred_chain): Same.
>>>>>     (dump_predicates): Same.
>>>>>     (destroy_predicate_vecs): Remove.
>>>>>     (execute_late_warn_uninitialized): New.
>>>>>     (get_cmp_code): Move to gimple-predicate-analysis.
>>>>>     (is_value_included_in): Same.
>>>>>     (value_sat_pred_p): Same.
>>>>>     (find_matching_predicate_in_rest_chains): Same.
>>>>>     (is_use_properly_guarded): Same.
>>>>>     (prune_uninit_phi_opnds): Same.
>>>>>     (find_var_cmp_const): Same.
>>>>>     (use_pred_not_overlap_with_undef_path_pred): Same.
>>>>>     (pred_equal_p): Same.
>>>>>     (is_neq_relop_p): Same.
>>>>>     (is_neq_zero_form_p): Same.
>>>>>     (pred_expr_equal_p): Same.
>>>>>     (is_pred_expr_subset_of): Same.
>>>>>     (is_pred_chain_subset_of): Same.
>>>>>     (is_included_in): Same.
>>>>>     (is_superset_of): Same.
>>>>>     (pred_neg_p): Same.
>>>>>     (simplify_pred): Same.
>>>>>     (simplify_preds_2): Same.
>>>>>     (simplify_preds_3): Same.
>>>>>     (simplify_preds_4): Same.
>>>>>     (simplify_preds): Same.
>>>>>     (push_pred): Same.
>>>>>     (push_to_worklist): Same.
>>>>>     (get_pred_info_from_cmp): Same.
>>>>>     (is_degenerated_phi): Same.
>>>>>     (normalize_one_pred_1): Same.
>>>>>     (normalize_one_pred): Same.
>>>>>     (normalize_one_pred_chain): Same.
>>>>>     (normalize_preds): Same.
>>>>>     (can_one_predicate_be_invalidated_p): Same.
>>>>>     (can_chain_union_be_invalidated_p): Same.
>>>>>     (uninit_uses_cannot_happen): Same.
>>>>>     (pass_late_warn_uninitialized::execute): Define.
>>>>>     * gimple-predicate-analysis.cc: New file.
>>>>>     * gimple-predicate-analysis.h: New file.
>>>> Thanks for tackling this.  It's something I think we've needed for a 
>>>> long time.
>>>>
>>>> I've only done a cursory review since this is primarily moving the 
>>>> analysis engine to its own file and class-ifying it.
>>>>
>>>> As we build additional consumers I won't be surprised if we have to 
>>>> adjust the exposed class API, but that's fine.   The first goal is 
>>>> to get the analysis disentangled from the consumer(s).
>>>>
>>>> OK.  Looking forward to seeing the analysis used elsewhere.
>>>
>>> Thanks, I just pushed it.
>>>
>>> As a heads up, I've been having some weird email problems lately and
>>> didn't find your approval until today, in my Trash folder.  Just in
>>> case there's fallout that I'm not responsive to, please either ping
>>> me on IRC or email my @redhat account.
>> Weird.  I wonder if google is trying to tell me something :-)
>>
>> Anyway,  it does seem to be triggering an ICE on nios2-linux-gnu and 
>> csky-linux-gnu (so far).
>>
>> Compile the attached code with -O2 -Wall  with a nios2-linux-gnu cross 
>> compiler.  You should get an ICE in the predicate bits.
> 
> Thanks.  An assert I added to help me debug the code is firing.
> Let me see if it's the assert that's wrong or if I messed up
> something else.

The good news is that modulo the ICE the code seems to be working
the same before and after my changes.  When added by itself, without
the rest of the changes, the assert still fires.  The bad news is
that I either misunderstood the code (and the assert is wrong) or
the code is buggy.

I've reduced the problem to a small, target-independent test case,
and opened bug 102403.

> 
> Martin
Martin Sebor Sept. 19, 2021, 11:24 p.m. UTC | #6
On 9/18/21 3:14 PM, Martin Sebor wrote:
> On 9/18/21 12:46 PM, Martin Sebor wrote:
>> On 9/17/21 10:08 PM, Jeff Law wrote:
>>>
>>>
>>> On 9/17/2021 4:05 PM, Martin Sebor wrote:
>>>> On 9/2/21 10:28 AM, Jeff Law via Gcc-patches wrote:
>>>>>
>>>>>
>>>>> On 8/30/2021 2:03 PM, Martin Sebor via Gcc-patches wrote:
>>>>>> The predicate analysis subset of the tree-ssa-uninit pass isn't
>>>>>> necessarily specific to the detection of uninitialized reads.
>>>>>> Suitably parameterized, the same core logic could be used in
>>>>>> other warning passes to improve their S/N ratio, or issue more
>>>>>> nuanced diagnostics (e.g., when an invalid access cannot be
>>>>>> ruled out but also need not in reality be unavoidable, issue
>>>>>> a "may be invalid" type of warning rather than "is invalid").
>>>>>>
>>>>>> Separating the predicate analysis logic from the uninitialized
>>>>>> pass and exposing a narrow API should also make it easier to
>>>>>> understand and evolve each part independently of the other,
>>>>>> or replace one with a better implementation without modifying
>>>>>> the other.(*)
>>>>>>
>>>>>> As the first step in this direction, the attached patch extracts
>>>>>> the predicate analysis logic out of the pass, turns the interface
>>>>>> into public class members, and hides the internals in either
>>>>>> private members or static functions defined in a new source file.
>>>>>> (**)
>>>>>>
>>>>>> The changes should have no externally observable effect (i.e.,
>>>>>> should cause no changes in warnings), except on the contents of
>>>>>> the uninitialized dump.  While making the changes I enhanced
>>>>>> the dumps to help me follow the logic.  Turning some previously
>>>>>> free-standing functions into members involved changing their
>>>>>> signatures and adjusting their callers.  While making these
>>>>>> changes I also renamed some of them as well some variables for
>>>>>> improved clarity.  Finally, I moved declarations of locals
>>>>>> closer to their point of initialization.
>>>>>>
>>>>>> Tested on x86_64-linux.  Besides the usual bootstrap/regtest
>>>>>> I also tentatively verified the generality of the new class
>>>>>> interfaces by making use of it in -Warray-bounds.  Besides there,
>>>>>> I'd like to make use of it in the new gimple-ssa-warn-access pass
>>>>>> and, longer term, any other flow-sensitive warnings that might
>>>>>> benefit from it.
>>>>>>
>>>>>> Martin
>>>>>>
>>>>>> [*] A review of open -Wuninitialized bugs I did while working
>>>>>> on this project made me aware of a number of opportunities to
>>>>>> improve the analyzer to reduce the number of false positives
>>>>>> -Wmaybe-uninitiailzed suffers from.
>>>>>>
>>>>>> [**] The class isn't fully general and, like the uninit pass,
>>>>>> only works with PHI nodes.  I plan to generalize it to compute
>>>>>> the set of predicates between any two basic blocks.
>>>>>>
>>>>>> gcc-predanal.diff
>>>>>>
>>>>>> Factor predidacte analysis out of tree-ssa-uninit.c into its own 
>>>>>> module.
>>>>>>
>>>>>> gcc/ChangeLog:
>>>>>>
>>>>>>     * Makefile.in (OBJS): Add gimple-predicate-analysis.o.
>>>>>>     * tree-ssa-uninit.c (max_phi_args): Move to 
>>>>>> gimple-predicate-analysis.
>>>>>>     (MASK_SET_BIT, MASK_TEST_BIT, MASK_EMPTY): Same.
>>>>>>     (check_defs):
>>>>>>     (can_skip_redundant_opnd):
>>>>>>     (compute_uninit_opnds_pos): Adjust to namespace change.
>>>>>>     (find_pdom): Move to gimple-predicate-analysis.cc.
>>>>>>     (find_dom): Same.
>>>>>>     (struct uninit_undef_val_t): New.
>>>>>>     (is_non_loop_exit_postdominating): Move to 
>>>>>> gimple-predicate-analysis.cc.
>>>>>>     (find_control_equiv_block): Same.
>>>>>>     (MAX_NUM_CHAINS, MAX_CHAIN_LEN, MAX_POSTDOM_CHECK): Same.
>>>>>>     (MAX_SWITCH_CASES): Same.
>>>>>>     (compute_control_dep_chain): Same.
>>>>>>     (find_uninit_use): Use predicate analyzer.
>>>>>>     (struct pred_info): Move to gimple-predicate-analysis.
>>>>>>     (convert_control_dep_chain_into_preds): Same.
>>>>>>     (find_predicates): Same.
>>>>>>     (collect_phi_def_edges): Same.
>>>>>>     (warn_uninitialized_phi): Use predicate analyzer.
>>>>>>     (find_def_preds): Move to gimple-predicate-analysis.
>>>>>>     (dump_pred_info): Same.
>>>>>>     (dump_pred_chain): Same.
>>>>>>     (dump_predicates): Same.
>>>>>>     (destroy_predicate_vecs): Remove.
>>>>>>     (execute_late_warn_uninitialized): New.
>>>>>>     (get_cmp_code): Move to gimple-predicate-analysis.
>>>>>>     (is_value_included_in): Same.
>>>>>>     (value_sat_pred_p): Same.
>>>>>>     (find_matching_predicate_in_rest_chains): Same.
>>>>>>     (is_use_properly_guarded): Same.
>>>>>>     (prune_uninit_phi_opnds): Same.
>>>>>>     (find_var_cmp_const): Same.
>>>>>>     (use_pred_not_overlap_with_undef_path_pred): Same.
>>>>>>     (pred_equal_p): Same.
>>>>>>     (is_neq_relop_p): Same.
>>>>>>     (is_neq_zero_form_p): Same.
>>>>>>     (pred_expr_equal_p): Same.
>>>>>>     (is_pred_expr_subset_of): Same.
>>>>>>     (is_pred_chain_subset_of): Same.
>>>>>>     (is_included_in): Same.
>>>>>>     (is_superset_of): Same.
>>>>>>     (pred_neg_p): Same.
>>>>>>     (simplify_pred): Same.
>>>>>>     (simplify_preds_2): Same.
>>>>>>     (simplify_preds_3): Same.
>>>>>>     (simplify_preds_4): Same.
>>>>>>     (simplify_preds): Same.
>>>>>>     (push_pred): Same.
>>>>>>     (push_to_worklist): Same.
>>>>>>     (get_pred_info_from_cmp): Same.
>>>>>>     (is_degenerated_phi): Same.
>>>>>>     (normalize_one_pred_1): Same.
>>>>>>     (normalize_one_pred): Same.
>>>>>>     (normalize_one_pred_chain): Same.
>>>>>>     (normalize_preds): Same.
>>>>>>     (can_one_predicate_be_invalidated_p): Same.
>>>>>>     (can_chain_union_be_invalidated_p): Same.
>>>>>>     (uninit_uses_cannot_happen): Same.
>>>>>>     (pass_late_warn_uninitialized::execute): Define.
>>>>>>     * gimple-predicate-analysis.cc: New file.
>>>>>>     * gimple-predicate-analysis.h: New file.
>>>>> Thanks for tackling this.  It's something I think we've needed for 
>>>>> a long time.
>>>>>
>>>>> I've only done a cursory review since this is primarily moving the 
>>>>> analysis engine to its own file and class-ifying it.
>>>>>
>>>>> As we build additional consumers I won't be surprised if we have to 
>>>>> adjust the exposed class API, but that's fine.   The first goal is 
>>>>> to get the analysis disentangled from the consumer(s).
>>>>>
>>>>> OK.  Looking forward to seeing the analysis used elsewhere.
>>>>
>>>> Thanks, I just pushed it.
>>>>
>>>> As a heads up, I've been having some weird email problems lately and
>>>> didn't find your approval until today, in my Trash folder.  Just in
>>>> case there's fallout that I'm not responsive to, please either ping
>>>> me on IRC or email my @redhat account.
>>> Weird.  I wonder if google is trying to tell me something :-)
>>>
>>> Anyway,  it does seem to be triggering an ICE on nios2-linux-gnu and 
>>> csky-linux-gnu (so far).
>>>
>>> Compile the attached code with -O2 -Wall  with a nios2-linux-gnu 
>>> cross compiler.  You should get an ICE in the predicate bits.
>>
>> Thanks.  An assert I added to help me debug the code is firing.
>> Let me see if it's the assert that's wrong or if I messed up
>> something else.
> 
> The good news is that modulo the ICE the code seems to be working
> the same before and after my changes.  When added by itself, without
> the rest of the changes, the assert still fires.  The bad news is
> that I either misunderstood the code (and the assert is wrong) or
> the code is buggy.
> 
> I've reduced the problem to a small, target-independent test case,
> and opened bug 102403.

It turned out to be my mistake.  I've fixed it in r12-3674.

Martin
Richard Biener Nov. 25, 2021, 10:18 a.m. UTC | #7
On Mon, Aug 30, 2021 at 10:06 PM Martin Sebor via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> The predicate analysis subset of the tree-ssa-uninit pass isn't
> necessarily specific to the detection of uninitialized reads.
> Suitably parameterized, the same core logic could be used in
> other warning passes to improve their S/N ratio, or issue more
> nuanced diagnostics (e.g., when an invalid access cannot be
> ruled out but also need not in reality be unavoidable, issue
> a "may be invalid" type of warning rather than "is invalid").
>
> Separating the predicate analysis logic from the uninitialized
> pass and exposing a narrow API should also make it easier to
> understand and evolve each part independently of the other,
> or replace one with a better implementation without modifying
> the other.(*)
>
> As the first step in this direction, the attached patch extracts
> the predicate analysis logic out of the pass, turns the interface
> into public class members, and hides the internals in either
> private members or static functions defined in a new source file.
> (**)
>
> The changes should have no externally observable effect (i.e.,
> should cause no changes in warnings), except on the contents of
> the uninitialized dump.  While making the changes I enhanced
> the dumps to help me follow the logic.  Turning some previously
> free-standing functions into members involved changing their
> signatures and adjusting their callers.  While making these
> changes I also renamed some of them as well some variables for
> improved clarity.  Finally, I moved declarations of locals
> closer to their point of initialization.
>
> Tested on x86_64-linux.  Besides the usual bootstrap/regtest
> I also tentatively verified the generality of the new class
> interfaces by making use of it in -Warray-bounds.  Besides there,
> I'd like to make use of it in the new gimple-ssa-warn-access pass
> and, longer term, any other flow-sensitive warnings that might
> benefit from it.

This changed can_chain_union_be_invalidated_p from

  for (size_t i = 0; i < uninit_pred.length (); ++i)
    {
      pred_chain c = uninit_pred[i];
      size_t j;
      for (j = 0; j < c.length (); ++j)
        if (can_one_predicate_be_invalidated_p (c[j], use_guard))
          break;

      /* If we were unable to invalidate any predicate in C, then there
         is a viable path from entry to the PHI where the PHI takes
         an uninitialized value and continues to a use of the PHI.  */
      if (j == c.length ())
        return false;
    }
  return true;

to

  for (unsigned i = 0; i < preds.length (); ++i)
    {
      const pred_chain &chain = preds[i];
      for (unsigned j = 0; j < chain.length (); ++j)
        if (can_be_invalidated_p (chain[j], guard))
          return true;

      /* If we were unable to invalidate any predicate in C, then there
         is a viable path from entry to the PHI where the PHI takes
         an interesting value and continues to a use of the PHI.  */
      return false;
    }
  return true;

which isn't semantically equivalent (it also uses overloading to
confuse me).  In particular the old code checked whether an
invalidation can happen for _each_ predicate in 'preds' while
the new one just checks preds[0], so the loop is pointless.

Catched by -Wunreachable-code complaining about unreachable
++i

Martin, was that change intended?

Richard.

>
> Martin
>
> [*] A review of open -Wuninitialized bugs I did while working
> on this project made me aware of a number of opportunities to
> improve the analyzer to reduce the number of false positives
> -Wmaybe-uninitiailzed suffers from.
>
> [**] The class isn't fully general and, like the uninit pass,
> only works with PHI nodes.  I plan to generalize it to compute
> the set of predicates between any two basic blocks.
Martin Sebor Nov. 29, 2021, 3:40 p.m. UTC | #8
On 11/25/21 3:18 AM, Richard Biener wrote:
> On Mon, Aug 30, 2021 at 10:06 PM Martin Sebor via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>>
>> The predicate analysis subset of the tree-ssa-uninit pass isn't
>> necessarily specific to the detection of uninitialized reads.
>> Suitably parameterized, the same core logic could be used in
>> other warning passes to improve their S/N ratio, or issue more
>> nuanced diagnostics (e.g., when an invalid access cannot be
>> ruled out but also need not in reality be unavoidable, issue
>> a "may be invalid" type of warning rather than "is invalid").
>>
>> Separating the predicate analysis logic from the uninitialized
>> pass and exposing a narrow API should also make it easier to
>> understand and evolve each part independently of the other,
>> or replace one with a better implementation without modifying
>> the other.(*)
>>
>> As the first step in this direction, the attached patch extracts
>> the predicate analysis logic out of the pass, turns the interface
>> into public class members, and hides the internals in either
>> private members or static functions defined in a new source file.
>> (**)
>>
>> The changes should have no externally observable effect (i.e.,
>> should cause no changes in warnings), except on the contents of
>> the uninitialized dump.  While making the changes I enhanced
>> the dumps to help me follow the logic.  Turning some previously
>> free-standing functions into members involved changing their
>> signatures and adjusting their callers.  While making these
>> changes I also renamed some of them as well some variables for
>> improved clarity.  Finally, I moved declarations of locals
>> closer to their point of initialization.
>>
>> Tested on x86_64-linux.  Besides the usual bootstrap/regtest
>> I also tentatively verified the generality of the new class
>> interfaces by making use of it in -Warray-bounds.  Besides there,
>> I'd like to make use of it in the new gimple-ssa-warn-access pass
>> and, longer term, any other flow-sensitive warnings that might
>> benefit from it.
> 
> This changed can_chain_union_be_invalidated_p from
> 
>    for (size_t i = 0; i < uninit_pred.length (); ++i)
>      {
>        pred_chain c = uninit_pred[i];
>        size_t j;
>        for (j = 0; j < c.length (); ++j)
>          if (can_one_predicate_be_invalidated_p (c[j], use_guard))
>            break;
> 
>        /* If we were unable to invalidate any predicate in C, then there
>           is a viable path from entry to the PHI where the PHI takes
>           an uninitialized value and continues to a use of the PHI.  */
>        if (j == c.length ())
>          return false;
>      }
>    return true;
> 
> to
> 
>    for (unsigned i = 0; i < preds.length (); ++i)
>      {
>        const pred_chain &chain = preds[i];
>        for (unsigned j = 0; j < chain.length (); ++j)
>          if (can_be_invalidated_p (chain[j], guard))
>            return true;
> 
>        /* If we were unable to invalidate any predicate in C, then there
>           is a viable path from entry to the PHI where the PHI takes
>           an interesting value and continues to a use of the PHI.  */
>        return false;
>      }
>    return true;
> 
> which isn't semantically equivalent (it also uses overloading to
> confuse me).  In particular the old code checked whether an
> invalidation can happen for _each_ predicate in 'preds' while
> the new one just checks preds[0], so the loop is pointless.
> 
> Catched by -Wunreachable-code complaining about unreachable
> ++i
> 
> Martin, was that change intended?

I didn't mean to make semantic changes (or to confuse you) so
the removal of the test is almost certainly an accident.  It's
interesting that the change hasn't caused any other trouble.
We should look into that.

Martin

> 
> Richard.
> 
>>
>> Martin
>>
>> [*] A review of open -Wuninitialized bugs I did while working
>> on this project made me aware of a number of opportunities to
>> improve the analyzer to reduce the number of false positives
>> -Wmaybe-uninitiailzed suffers from.
>>
>> [**] The class isn't fully general and, like the uninit pass,
>> only works with PHI nodes.  I plan to generalize it to compute
>> the set of predicates between any two basic blocks.
Richard Biener Nov. 30, 2021, 7:39 a.m. UTC | #9
On Mon, Nov 29, 2021 at 4:40 PM Martin Sebor <msebor@gmail.com> wrote:
>
> On 11/25/21 3:18 AM, Richard Biener wrote:
> > On Mon, Aug 30, 2021 at 10:06 PM Martin Sebor via Gcc-patches
> > <gcc-patches@gcc.gnu.org> wrote:
> >>
> >> The predicate analysis subset of the tree-ssa-uninit pass isn't
> >> necessarily specific to the detection of uninitialized reads.
> >> Suitably parameterized, the same core logic could be used in
> >> other warning passes to improve their S/N ratio, or issue more
> >> nuanced diagnostics (e.g., when an invalid access cannot be
> >> ruled out but also need not in reality be unavoidable, issue
> >> a "may be invalid" type of warning rather than "is invalid").
> >>
> >> Separating the predicate analysis logic from the uninitialized
> >> pass and exposing a narrow API should also make it easier to
> >> understand and evolve each part independently of the other,
> >> or replace one with a better implementation without modifying
> >> the other.(*)
> >>
> >> As the first step in this direction, the attached patch extracts
> >> the predicate analysis logic out of the pass, turns the interface
> >> into public class members, and hides the internals in either
> >> private members or static functions defined in a new source file.
> >> (**)
> >>
> >> The changes should have no externally observable effect (i.e.,
> >> should cause no changes in warnings), except on the contents of
> >> the uninitialized dump.  While making the changes I enhanced
> >> the dumps to help me follow the logic.  Turning some previously
> >> free-standing functions into members involved changing their
> >> signatures and adjusting their callers.  While making these
> >> changes I also renamed some of them as well some variables for
> >> improved clarity.  Finally, I moved declarations of locals
> >> closer to their point of initialization.
> >>
> >> Tested on x86_64-linux.  Besides the usual bootstrap/regtest
> >> I also tentatively verified the generality of the new class
> >> interfaces by making use of it in -Warray-bounds.  Besides there,
> >> I'd like to make use of it in the new gimple-ssa-warn-access pass
> >> and, longer term, any other flow-sensitive warnings that might
> >> benefit from it.
> >
> > This changed can_chain_union_be_invalidated_p from
> >
> >    for (size_t i = 0; i < uninit_pred.length (); ++i)
> >      {
> >        pred_chain c = uninit_pred[i];
> >        size_t j;
> >        for (j = 0; j < c.length (); ++j)
> >          if (can_one_predicate_be_invalidated_p (c[j], use_guard))
> >            break;
> >
> >        /* If we were unable to invalidate any predicate in C, then there
> >           is a viable path from entry to the PHI where the PHI takes
> >           an uninitialized value and continues to a use of the PHI.  */
> >        if (j == c.length ())
> >          return false;
> >      }
> >    return true;
> >
> > to
> >
> >    for (unsigned i = 0; i < preds.length (); ++i)
> >      {
> >        const pred_chain &chain = preds[i];
> >        for (unsigned j = 0; j < chain.length (); ++j)
> >          if (can_be_invalidated_p (chain[j], guard))
> >            return true;
> >
> >        /* If we were unable to invalidate any predicate in C, then there
> >           is a viable path from entry to the PHI where the PHI takes
> >           an interesting value and continues to a use of the PHI.  */
> >        return false;
> >      }
> >    return true;
> >
> > which isn't semantically equivalent (it also uses overloading to
> > confuse me).  In particular the old code checked whether an
> > invalidation can happen for _each_ predicate in 'preds' while
> > the new one just checks preds[0], so the loop is pointless.
> >
> > Catched by -Wunreachable-code complaining about unreachable
> > ++i
> >
> > Martin, was that change intended?
>
> I didn't mean to make semantic changes (or to confuse you) so
> the removal of the test is almost certainly an accident.  It's
> interesting that the change hasn't caused any other trouble.
> We should look into that.

Jeff meanwhile approved restoring the original.  But yes, it's
odd that this did not have any visible effect (maybe fixing
the mistake resolved some uninit regressions - but IIRC none
were bisected to that rev.)

Richard.

>
> Martin
>
> >
> > Richard.
> >
> >>
> >> Martin
> >>
> >> [*] A review of open -Wuninitialized bugs I did while working
> >> on this project made me aware of a number of opportunities to
> >> improve the analyzer to reduce the number of false positives
> >> -Wmaybe-uninitiailzed suffers from.
> >>
> >> [**] The class isn't fully general and, like the uninit pass,
> >> only works with PHI nodes.  I plan to generalize it to compute
> >> the set of predicates between any two basic blocks.
>
diff mbox series

Patch

Factor predidacte analysis out of tree-ssa-uninit.c into its own module.

gcc/ChangeLog:

	* Makefile.in (OBJS): Add gimple-predicate-analysis.o.
	* tree-ssa-uninit.c (max_phi_args): Move to gimple-predicate-analysis.
	(MASK_SET_BIT, MASK_TEST_BIT, MASK_EMPTY): Same.
	(check_defs):
	(can_skip_redundant_opnd):
	(compute_uninit_opnds_pos): Adjust to namespace change.
	(find_pdom): Move to gimple-predicate-analysis.cc.
	(find_dom): Same.
	(struct uninit_undef_val_t): New.
	(is_non_loop_exit_postdominating): Move to gimple-predicate-analysis.cc.
	(find_control_equiv_block): Same.
	(MAX_NUM_CHAINS, MAX_CHAIN_LEN, MAX_POSTDOM_CHECK): Same.
	(MAX_SWITCH_CASES): Same.
	(compute_control_dep_chain): Same.
	(find_uninit_use): Use predicate analyzer.
	(struct pred_info): Move to gimple-predicate-analysis.
	(convert_control_dep_chain_into_preds): Same.
	(find_predicates): Same.
	(collect_phi_def_edges): Same.
	(warn_uninitialized_phi): Use predicate analyzer.
	(find_def_preds): Move to gimple-predicate-analysis.
	(dump_pred_info): Same.
	(dump_pred_chain): Same.
	(dump_predicates): Same.
	(destroy_predicate_vecs): Remove.
	(execute_late_warn_uninitialized): New.
	(get_cmp_code): Move to gimple-predicate-analysis.
	(is_value_included_in): Same.
	(value_sat_pred_p): Same.
	(find_matching_predicate_in_rest_chains): Same.
	(is_use_properly_guarded): Same.
	(prune_uninit_phi_opnds): Same.
	(find_var_cmp_const): Same.
	(use_pred_not_overlap_with_undef_path_pred): Same.
	(pred_equal_p): Same.
	(is_neq_relop_p): Same.
	(is_neq_zero_form_p): Same.
	(pred_expr_equal_p): Same.
	(is_pred_expr_subset_of): Same.
	(is_pred_chain_subset_of): Same.
	(is_included_in): Same.
	(is_superset_of): Same.
	(pred_neg_p): Same.
	(simplify_pred): Same.
	(simplify_preds_2): Same.
	(simplify_preds_3): Same.
	(simplify_preds_4): Same.
	(simplify_preds): Same.
	(push_pred): Same.
	(push_to_worklist): Same.
	(get_pred_info_from_cmp): Same.
	(is_degenerated_phi): Same.
	(normalize_one_pred_1): Same.
	(normalize_one_pred): Same.
	(normalize_one_pred_chain): Same.
	(normalize_preds): Same.
	(can_one_predicate_be_invalidated_p): Same.
	(can_chain_union_be_invalidated_p): Same.
	(uninit_uses_cannot_happen): Same.
	(pass_late_warn_uninitialized::execute): Define.
	* gimple-predicate-analysis.cc: New file.
	* gimple-predicate-analysis.h: New file.

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 9714fcaac37..f22e4b5f413 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1400,6 +1400,7 @@  OBJS = \
 	gimple-loop-jam.o \
 	gimple-loop-versioning.o \
 	gimple-low.o \
+	gimple-predicate-analysis.o \
 	gimple-pretty-print.o \
 	gimple-range.o \
 	gimple-range-cache.o \
diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc
new file mode 100644
index 00000000000..3404f2d630a
--- /dev/null
+++ b/gcc/gimple-predicate-analysis.cc
@@ -0,0 +1,2400 @@ 
+/* Support for simple predicate analysis.
+
+   Copyright (C) 2001-2021 Free Software Foundation, Inc.
+   Contributed by Xinliang David Li <davidxl@google.com>
+   Generalized by Martin Sebor <msebor@redhat.com>
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GCC is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+#define INCLUDE_STRING
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "backend.h"
+#include "tree.h"
+#include "gimple.h"
+#include "tree-pass.h"
+#include "ssa.h"
+#include "gimple-pretty-print.h"
+#include "diagnostic-core.h"
+#include "fold-const.h"
+#include "gimple-iterator.h"
+#include "tree-ssa.h"
+#include "tree-cfg.h"
+#include "cfghooks.h"
+#include "attribs.h"
+#include "builtins.h"
+#include "calls.h"
+#include "value-query.h"
+
+#include "gimple-predicate-analysis.h"
+
+#define DEBUG_PREDICATE_ANALYZER 1
+
+/* Find the immediate postdominator of the specified basic block BB.  */
+
+static inline basic_block
+find_pdom (basic_block bb)
+{
+  basic_block exit_bb = EXIT_BLOCK_PTR_FOR_FN (cfun);
+  if (bb == exit_bb)
+    return exit_bb;
+
+  if (basic_block pdom = get_immediate_dominator (CDI_POST_DOMINATORS, bb))
+    return pdom;
+
+  return exit_bb;
+}
+
+/* Find the immediate dominator of the specified basic block BB.  */
+
+static inline basic_block
+find_dom (basic_block bb)
+{
+  basic_block entry_bb = ENTRY_BLOCK_PTR_FOR_FN (cfun);
+  if (bb == entry_bb)
+    return entry_bb;
+
+  if (basic_block dom = get_immediate_dominator (CDI_DOMINATORS, bb))
+    return dom;
+
+  return entry_bb;
+}
+
+/* Return true if BB1 is postdominating BB2 and BB1 is not a loop exit
+   bb.  The loop exit bb check is simple and does not cover all cases.  */
+
+static bool
+is_non_loop_exit_postdominating (basic_block bb1, basic_block bb2)
+{
+  if (!dominated_by_p (CDI_POST_DOMINATORS, bb2, bb1))
+    return false;
+
+  if (single_pred_p (bb1) && !single_succ_p (bb2))
+    return false;
+
+  return true;
+}
+
+/* Find BB's closest postdominator that is its control equivalent (i.e.,
+   that's controlled by the same predicate).  */
+
+static inline basic_block
+find_control_equiv_block (basic_block bb)
+{
+  basic_block pdom = find_pdom (bb);
+
+  /* Skip the postdominating bb that is also a loop exit.  */
+  if (!is_non_loop_exit_postdominating (pdom, bb))
+    return NULL;
+
+  /* If the postdominator is dominated by BB, return it.  */
+  if (dominated_by_p (CDI_DOMINATORS, pdom, bb))
+    return pdom;
+
+  return NULL;
+}
+
+/* Return true if X1 is the negation of X2.  */
+
+static inline bool
+pred_neg_p (const pred_info &x1, const pred_info &x2)
+{
+  if (!operand_equal_p (x1.pred_lhs, x2.pred_lhs, 0)
+      || !operand_equal_p (x1.pred_rhs, x2.pred_rhs, 0))
+    return false;
+
+  tree_code c1 = x1.cond_code, c2;
+  if (x1.invert == x2.invert)
+    c2 = invert_tree_comparison (x2.cond_code, false);
+  else
+    c2 = x2.cond_code;
+
+  return c1 == c2;
+}
+
+/* Return whether the condition (VAL CMPC BOUNDARY) is true.  */
+
+static bool
+is_value_included_in (tree val, tree boundary, tree_code cmpc)
+{
+  /* Only handle integer constant here.  */
+  if (TREE_CODE (val) != INTEGER_CST || TREE_CODE (boundary) != INTEGER_CST)
+    return true;
+
+  bool inverted = false;
+  if (cmpc == GE_EXPR || cmpc == GT_EXPR || cmpc == NE_EXPR)
+    {
+      cmpc = invert_tree_comparison (cmpc, false);
+      inverted = true;
+    }
+
+  bool result;
+  if (cmpc == EQ_EXPR)
+    result = tree_int_cst_equal (val, boundary);
+  else if (cmpc == LT_EXPR)
+    result = tree_int_cst_lt (val, boundary);
+  else
+    {
+      gcc_assert (cmpc == LE_EXPR);
+      result = tree_int_cst_le (val, boundary);
+    }
+
+  if (inverted)
+    result ^= 1;
+
+  return result;
+}
+
+/* Format the vector of edges EV as a string.  */
+
+static std::string
+format_edge_vec (const vec<edge> &ev)
+{
+  std::string str;
+
+  unsigned n = ev.length ();
+  for (unsigned i = 0; i < n; ++i)
+    {
+      char es[32];
+      const_edge e = ev[i];
+      sprintf (es, "%u", e->src->index);
+      str += es;
+      if (i + 1 < n)
+	str += " -> ";
+    }
+  return str;
+}
+
+/* Format the first N elements of the array of vector of edges EVA as
+   a string.  */
+
+static std::string
+format_edge_vecs (const vec<edge> eva[], unsigned n)
+{
+  std::string str;
+
+  for (unsigned i = 0; i != n; ++i)
+    {
+      str += '{';
+      str += format_edge_vec (eva[i]);
+      str += '}';
+      if (i + 1 < n)
+	str += ", ";
+    }
+  return str;
+}
+
+/* Dump a single pred_info to DUMP_FILE.  */
+
+static void
+dump_pred_info (const pred_info &pred)
+{
+  if (pred.invert)
+    fprintf (dump_file, "NOT (");
+  print_generic_expr (dump_file, pred.pred_lhs);
+  fprintf (dump_file, " %s ", op_symbol_code (pred.cond_code));
+  print_generic_expr (dump_file, pred.pred_rhs);
+  if (pred.invert)
+    fputc (')', dump_file);
+}
+
+/* Dump a pred_chain to DUMP_FILE.  */
+
+static void
+dump_pred_chain (const pred_chain &chain)
+{
+  unsigned np = chain.length ();
+  if (np > 1)
+    fprintf (dump_file, "AND (");
+
+  for (unsigned j = 0; j < np; j++)
+    {
+      dump_pred_info (chain[j]);
+      if (j < np - 1)
+	fprintf (dump_file, ", ");
+      else if (j > 0)
+	fputc (')', dump_file);
+    }
+}
+
+/* Dump the predicate chain PREDS for STMT, prefixed by MSG.  */
+
+static void
+dump_predicates (gimple *stmt, const pred_chain_union &preds, const char *msg)
+{
+  fprintf (dump_file, "%s", msg);
+  if (stmt)
+    {
+      print_gimple_stmt (dump_file, stmt, 0);
+      fprintf (dump_file, "is guarded by:\n");
+    }
+
+  unsigned np = preds.length ();
+  if (np > 1)
+    fprintf (dump_file, "OR (");
+  for (unsigned i = 0; i < np; i++)
+    {
+      dump_pred_chain (preds[i]);
+      if (i < np - 1)
+	fprintf (dump_file, ", ");
+      else if (i > 0)
+	fputc (')', dump_file);
+    }
+  fputc ('\n', dump_file);
+}
+
+/* Dump the first NCHAINS elements of the DEP_CHAINS array into DUMP_FILE.  */
+
+static void
+dump_dep_chains (const auto_vec<edge> dep_chains[], unsigned nchains)
+{
+  if (!dump_file)
+    return;
+
+  for (unsigned i = 0; i != nchains; ++i)
+    {
+      const auto_vec<edge> &v = dep_chains[i];
+      unsigned n = v.length ();
+      for (unsigned j = 0; j != n; ++j)
+	{
+	  fprintf (dump_file, "%u", v[j]->src->index);
+	  if (j + 1 < n)
+	    fprintf (dump_file, " -> ");
+	}
+      fputc ('\n', dump_file);
+    }
+}
+
+/* Return the 'normalized' conditional code with operand swapping
+   and condition inversion controlled by SWAP_COND and INVERT.  */
+
+static tree_code
+get_cmp_code (tree_code orig_cmp_code, bool swap_cond, bool invert)
+{
+  tree_code tc = orig_cmp_code;
+
+  if (swap_cond)
+    tc = swap_tree_comparison (orig_cmp_code);
+  if (invert)
+    tc = invert_tree_comparison (tc, false);
+
+  switch (tc)
+    {
+    case LT_EXPR:
+    case LE_EXPR:
+    case GT_EXPR:
+    case GE_EXPR:
+    case EQ_EXPR:
+    case NE_EXPR:
+      break;
+    default:
+      return ERROR_MARK;
+    }
+  return tc;
+}
+
+/* Return true if PRED is common among all predicate chains in PREDS
+   (and therefore can be factored out).  */
+
+static bool
+find_matching_predicate_in_rest_chains (const pred_info &pred,
+					const pred_chain_union &preds)
+{
+  /* Trival case.  */
+  if (preds.length () == 1)
+    return true;
+
+  for (unsigned i = 1; i < preds.length (); i++)
+    {
+      bool found = false;
+      const pred_chain &chain = preds[i];
+      unsigned n = chain.length ();
+      for (unsigned j = 0; j < n; j++)
+	{
+	  const pred_info &pred2 = chain[j];
+	  /* Can relax the condition comparison to not use address
+	     comparison.  However, the most common case is that
+	     multiple control dependent paths share a common path
+	     prefix, so address comparison should be ok.  */
+	  if (operand_equal_p (pred2.pred_lhs, pred.pred_lhs, 0)
+	      && operand_equal_p (pred2.pred_rhs, pred.pred_rhs, 0)
+	      && pred2.invert == pred.invert)
+	    {
+	      found = true;
+	      break;
+	    }
+	}
+      if (!found)
+	return false;
+    }
+  return true;
+}
+
+/* Find a predicate to examine against paths of interest.  If there
+   is no predicate of the "FLAG_VAR CMP CONST" form, try to find one
+   of that's the form "FLAG_VAR CMP FLAG_VAR" with value range info.
+   PHI is the phi node whose incoming (interesting) paths need to be
+   examined.  On success, return the comparison code, set defintion
+   gimple of FLAG_DEF and BOUNDARY_CST.  Otherwise return ERROR_MARK.  */
+
+static tree_code
+find_var_cmp_const (pred_chain_union preds, gphi *phi, gimple **flag_def,
+		    tree *boundary_cst)
+{
+  tree_code vrinfo_code = ERROR_MARK;
+  gimple *vrinfo_def = NULL;
+  tree vrinfo_cst = NULL;
+
+  gcc_assert (preds.length () > 0);
+  pred_chain chain = preds[0];
+  for (unsigned i = 0; i < chain.length (); i++)
+    {
+      bool use_vrinfo_p = false;
+      const pred_info &pred = chain[i];
+      tree cond_lhs = pred.pred_lhs;
+      tree cond_rhs = pred.pred_rhs;
+      if (cond_lhs == NULL_TREE || cond_rhs == NULL_TREE)
+	continue;
+
+      tree_code code = get_cmp_code (pred.cond_code, false, pred.invert);
+      if (code == ERROR_MARK)
+	continue;
+
+      /* Convert to the canonical form SSA_NAME CMP CONSTANT.  */
+      if (TREE_CODE (cond_lhs) == SSA_NAME
+	  && is_gimple_constant (cond_rhs))
+	;
+      else if (TREE_CODE (cond_rhs) == SSA_NAME
+	       && is_gimple_constant (cond_lhs))
+	{
+	  std::swap (cond_lhs, cond_rhs);
+	  if ((code = get_cmp_code (code, true, false)) == ERROR_MARK)
+	    continue;
+	}
+      /* Check if we can take advantage of FLAG_VAR COMP FLAG_VAR predicate
+	 with value range info.  Note only first of such case is handled.  */
+      else if (vrinfo_code == ERROR_MARK
+	       && TREE_CODE (cond_lhs) == SSA_NAME
+	       && TREE_CODE (cond_rhs) == SSA_NAME)
+	{
+	  gimple* lhs_def = SSA_NAME_DEF_STMT (cond_lhs);
+	  if (!lhs_def || gimple_code (lhs_def) != GIMPLE_PHI
+	      || gimple_bb (lhs_def) != gimple_bb (phi))
+	    {
+	      std::swap (cond_lhs, cond_rhs);
+	      if ((code = get_cmp_code (code, true, false)) == ERROR_MARK)
+		continue;
+	    }
+
+	  /* Check value range info of rhs, do following transforms:
+	       flag_var < [min, max]  ->  flag_var < max
+	       flag_var > [min, max]  ->  flag_var > min
+
+	     We can also transform LE_EXPR/GE_EXPR to LT_EXPR/GT_EXPR:
+	       flag_var <= [min, max] ->  flag_var < [min, max+1]
+	       flag_var >= [min, max] ->  flag_var > [min-1, max]
+	     if no overflow/wrap.  */
+	  tree type = TREE_TYPE (cond_lhs);
+	  value_range r;
+	  if (!INTEGRAL_TYPE_P (type)
+	      || !get_range_query (cfun)->range_of_expr (r, cond_rhs)
+	      || r.kind () != VR_RANGE)
+	    continue;
+
+	  wide_int min = r.lower_bound ();
+	  wide_int max = r.upper_bound ();
+	  if (code == LE_EXPR
+	      && max != wi::max_value (TYPE_PRECISION (type), TYPE_SIGN (type)))
+	    {
+	      code = LT_EXPR;
+	      max = max + 1;
+	    }
+	  if (code == GE_EXPR
+	      && min != wi::min_value (TYPE_PRECISION (type), TYPE_SIGN (type)))
+	    {
+	      code = GT_EXPR;
+	      min = min - 1;
+	    }
+	  if (code == LT_EXPR)
+	    cond_rhs = wide_int_to_tree (type, max);
+	  else if (code == GT_EXPR)
+	    cond_rhs = wide_int_to_tree (type, min);
+	  else
+	    continue;
+
+	  use_vrinfo_p = true;
+	}
+      else
+	continue;
+
+      if ((*flag_def = SSA_NAME_DEF_STMT (cond_lhs)) == NULL)
+	continue;
+
+      if (gimple_code (*flag_def) != GIMPLE_PHI
+	  || gimple_bb (*flag_def) != gimple_bb (phi)
+	  || !find_matching_predicate_in_rest_chains (pred, preds))
+	continue;
+
+      /* Return if any "flag_var comp const" predicate is found.  */
+      if (!use_vrinfo_p)
+	{
+	  *boundary_cst = cond_rhs;
+	  return code;
+	}
+      /* Record if any "flag_var comp flag_var[vinfo]" predicate is found.  */
+      else if (vrinfo_code == ERROR_MARK)
+	{
+	  vrinfo_code = code;
+	  vrinfo_def = *flag_def;
+	  vrinfo_cst = cond_rhs;
+	}
+    }
+  /* Return the "flag_var cmp flag_var[vinfo]" predicate we found.  */
+  if (vrinfo_code != ERROR_MARK)
+    {
+      *flag_def = vrinfo_def;
+      *boundary_cst = vrinfo_cst;
+    }
+  return vrinfo_code;
+}
+
+/* Return true if all interesting opnds are pruned, false otherwise.
+   PHI is the phi node with interesting operands, OPNDS is the bitmap
+   of the interesting operand positions, FLAG_DEF is the statement
+   defining the flag guarding the use of the PHI output, BOUNDARY_CST
+   is the const value used in the predicate associated with the flag,
+   CMP_CODE is the comparison code used in the predicate, VISITED_PHIS
+   is the pointer set of phis visited, and VISITED_FLAG_PHIS is
+   the pointer to the pointer set of flag definitions that are also
+   phis.
+
+   Example scenario:
+
+   BB1:
+     flag_1 = phi <0, 1>			// (1)
+     var_1  = phi <undef, some_val>
+
+
+   BB2:
+     flag_2 = phi <0,   flag_1, flag_1>		// (2)
+     var_2  = phi <undef, var_1, var_1>
+     if (flag_2 == 1)
+       goto BB3;
+
+   BB3:
+     use of var_2				// (3)
+
+   Because some flag arg in (1) is not constant, if we do not look into
+   the flag phis recursively, it is conservatively treated as unknown and
+   var_1 is thought to flow into use at (3).  Since var_1 is potentially
+   uninitialized a false warning will be emitted.
+   Checking recursively into (1), the compiler can find out that only
+   some_val (which is defined) can flow into (3) which is OK.  */
+
+static bool
+prune_phi_opnds (gphi *phi, unsigned opnds, gphi *flag_def,
+		 tree boundary_cst, tree_code cmp_code,
+		 predicate::func_t &eval,
+		 hash_set<gphi *> *visited_phis,
+		 bitmap *visited_flag_phis)
+{
+  /* The Boolean predicate guarding the PHI definition.  Initialized
+     lazily from PHI in the first call to is_use_guarded() and cached
+     for subsequent iterations.  */
+  predicate def_preds (eval);
+
+  unsigned n = MIN (eval.max_phi_args, gimple_phi_num_args (flag_def));
+  for (unsigned i = 0; i < n; i++)
+    {
+      if (!MASK_TEST_BIT (opnds, i))
+	continue;
+
+      tree flag_arg = gimple_phi_arg_def (flag_def, i);
+      if (!is_gimple_constant (flag_arg))
+	{
+	  if (TREE_CODE (flag_arg) != SSA_NAME)
+	    return false;
+
+	  gphi *flag_arg_def = dyn_cast<gphi *> (SSA_NAME_DEF_STMT (flag_arg));
+	  if (!flag_arg_def)
+	    return false;
+
+	  tree phi_arg = gimple_phi_arg_def (phi, i);
+	  if (TREE_CODE (phi_arg) != SSA_NAME)
+	    return false;
+
+	  gphi *phi_arg_def = dyn_cast<gphi *> (SSA_NAME_DEF_STMT (phi_arg));
+	  if (!phi_arg_def)
+	    return false;
+
+	  if (gimple_bb (phi_arg_def) != gimple_bb (flag_arg_def))
+	    return false;
+
+	  if (!*visited_flag_phis)
+	    *visited_flag_phis = BITMAP_ALLOC (NULL);
+
+	  tree phi_result = gimple_phi_result (flag_arg_def);
+	  if (bitmap_bit_p (*visited_flag_phis, SSA_NAME_VERSION (phi_result)))
+	    return false;
+
+	  bitmap_set_bit (*visited_flag_phis, SSA_NAME_VERSION (phi_result));
+
+	  /* Now recursively try to prune the interesting phi args.  */
+	  unsigned opnds_arg_phi = eval.phi_arg_set (phi_arg_def);
+	  if (!prune_phi_opnds (phi_arg_def, opnds_arg_phi, flag_arg_def,
+				boundary_cst, cmp_code, eval, visited_phis,
+				visited_flag_phis))
+	    return false;
+
+	  bitmap_clear_bit (*visited_flag_phis, SSA_NAME_VERSION (phi_result));
+	  continue;
+	}
+
+      /* Now check if the constant is in the guarded range.  */
+      if (is_value_included_in (flag_arg, boundary_cst, cmp_code))
+	{
+	  /* Now that we know that this undefined edge is not pruned.
+	     If the operand is defined by another phi, we can further
+	     prune the incoming edges of that phi by checking
+	     the predicates of this operands.  */
+
+	  tree opnd = gimple_phi_arg_def (phi, i);
+	  gimple *opnd_def = SSA_NAME_DEF_STMT (opnd);
+	  if (gphi *opnd_def_phi = dyn_cast <gphi *> (opnd_def))
+	    {
+	      unsigned opnds2 = eval.phi_arg_set (opnd_def_phi);
+	      if (!MASK_EMPTY (opnds2))
+		{
+		  edge opnd_edge = gimple_phi_arg_edge (phi, i);
+		  if (def_preds.is_use_guarded (phi, opnd_edge->src,
+						opnd_def_phi, opnds2,
+						visited_phis))
+		    return false;
+		}
+	    }
+	  else
+	    return false;
+	}
+    }
+
+  return true;
+}
+
+/* Recursively compute the set PHI's incoming edges with "uninteresting"
+   operands of a phi chain, i.e., those for which EVAL returns false.
+   CD_ROOT is the control dependence root from which edges are collected
+   up the CFG nodes that it's dominated by.  *EDGES holds the result, and
+   VISITED is used for detecting cycles.  */
+
+static void
+collect_phi_def_edges (gphi *phi, basic_block cd_root, auto_vec<edge> *edges,
+		       predicate::func_t &eval, hash_set<gimple *> *visited)
+{
+  if (visited->elements () == 0
+      && DEBUG_PREDICATE_ANALYZER
+      && dump_file)
+    {
+      fprintf (dump_file, "%s for cd_root %u and ",
+	       __func__, cd_root->index);
+      print_gimple_stmt (dump_file, phi, 0);
+
+    }
+
+  if (visited->add (phi))
+    return;
+
+  unsigned n = gimple_phi_num_args (phi);
+  for (unsigned i = 0; i < n; i++)
+    {
+      edge opnd_edge = gimple_phi_arg_edge (phi, i);
+      tree opnd = gimple_phi_arg_def (phi, i);
+
+      if (TREE_CODE (opnd) == SSA_NAME)
+	{
+	  gimple *def = SSA_NAME_DEF_STMT (opnd);
+
+	  if (gimple_code (def) == GIMPLE_PHI
+	      && dominated_by_p (CDI_DOMINATORS, gimple_bb (def), cd_root))
+	    collect_phi_def_edges (as_a<gphi *> (def), cd_root, edges, eval,
+				   visited);
+	  else if (!eval (opnd))
+	    {
+	      if (dump_file && (dump_flags & TDF_DETAILS))
+		{
+		  fprintf (dump_file,
+			   "\tFound def edge %i -> %i for cd_root %i "
+			   "and operand %u of: ",
+			   opnd_edge->src->index, opnd_edge->dest->index,
+			   cd_root->index, i);
+		  print_gimple_stmt (dump_file, phi, 0);
+		}
+	      edges->safe_push (opnd_edge);
+	    }
+	}
+      else
+	{
+	  if (dump_file && (dump_flags & TDF_DETAILS))
+	    {
+	      fprintf (dump_file,
+		       "\tFound def edge %i -> %i for cd_root %i "
+		       "and operand %u of: ",
+		       opnd_edge->src->index, opnd_edge->dest->index,
+		       cd_root->index, i);
+	      print_gimple_stmt (dump_file, phi, 0);
+	    }
+
+	  if (!eval (opnd))
+	    edges->safe_push (opnd_edge);
+	}
+    }
+}
+
+/* Return an expression corresponding to the predicate PRED.  */
+
+static tree
+build_pred_expr (const pred_info &pred)
+{
+  tree_code cond_code = pred.cond_code;
+  tree lhs = pred.pred_lhs;
+  tree rhs = pred.pred_rhs;
+
+  if (pred.invert)
+    cond_code = invert_tree_comparison (cond_code, false);
+
+  return build2 (cond_code, TREE_TYPE (lhs), lhs, rhs);
+}
+
+/* Return an expression corresponding to PREDS.  */
+
+static tree
+build_pred_expr (const pred_chain_union &preds, bool invert = false)
+{
+  tree_code code = invert ? TRUTH_AND_EXPR : TRUTH_OR_EXPR;
+  tree_code subcode = invert ? TRUTH_OR_EXPR : TRUTH_AND_EXPR;
+
+  tree expr = NULL_TREE;
+  for (unsigned i = 0; i != preds.length (); ++i)
+    {
+      tree subexpr = NULL_TREE;
+      for (unsigned j = 0; j != preds[i].length (); ++j)
+       {
+         const pred_info &pi = preds[i][j];
+         tree cond = build_pred_expr (pi);
+	 if (invert)
+	   cond = invert_truthvalue (cond);
+         subexpr = subexpr ? build2 (subcode, boolean_type_node,
+                                     subexpr, cond) : cond;
+       }
+      if (expr)
+       expr = build2 (code, boolean_type_node, expr, subexpr);
+      else
+       expr = subexpr;
+    }
+
+  return expr;
+}
+
+/* Return a bitset of all PHI arguments or zero if there are too many.  */
+
+unsigned
+predicate::func_t::phi_arg_set (gphi *phi)
+{
+  unsigned n = gimple_phi_num_args (phi);
+
+  if (max_phi_args < n)
+    return 0;
+
+  /* Set the least significant N bits.  */
+  return (1U << n) - 1;
+}
+
+/* Determine if the predicate set of the use does not overlap with that
+   of the interesting paths.  The most common senario of guarded use is
+   in Example 1:
+     Example 1:
+	   if (some_cond)
+	   {
+	      x = ...;   // set x to valid
+	      flag = true;
+	   }
+
+	    ... some code ...
+
+	   if (flag)
+	      use (x);   // use when x is valid
+
+     The real world examples are usually more complicated, but similar
+     and usually result from inlining:
+
+	 bool init_func (int * x)
+	 {
+	     if (some_cond)
+		return false;
+	     *x  =  ...;   // set *x to valid
+	     return true;
+	 }
+
+	 void foo (..)
+	 {
+	     int x;
+
+	     if (!init_func (&x))
+		return;
+
+	     .. some_code ...
+	     use (x);      // use when x is valid
+	 }
+
+     Another possible use scenario is in the following trivial example:
+
+     Example 2:
+	  if (n > 0)
+	     x = 1;
+	  ...
+	  if (n > 0)
+	    {
+	      if (m < 2)
+		 ... = x;
+	    }
+
+     Predicate analysis needs to compute the composite predicate:
+
+       1) 'x' use predicate: (n > 0) .AND. (m < 2)
+       2) 'x' default value  (non-def) predicate: .NOT. (n > 0)
+       (the predicate chain for phi operand defs can be computed
+       starting from a bb that is control equivalent to the phi's
+       bb and is dominating the operand def.)
+
+       and check overlapping:
+	  (n > 0) .AND. (m < 2) .AND. (.NOT. (n > 0))
+	<==> false
+
+     This implementation provides a framework that can handle different
+     scenarios.  (Note that many simple cases are handled properly without
+     the predicate analysis if jump threading eliminates the merge point
+     thus makes path-sensitive analysis unnecessary.)
+
+     PHI is the phi node whose incoming (undefined) paths need to be
+     pruned, and OPNDS is the bitmap holding interesting operand
+     positions.  VISITED is the pointer set of phi stmts being
+     checked.  */
+
+bool
+predicate::overlap (gphi *phi, unsigned opnds, hash_set<gphi *> *visited)
+{
+  gimple *flag_def = NULL;
+  tree boundary_cst = NULL_TREE;
+  bitmap visited_flag_phis = NULL;
+
+  /* Find within the common prefix of multiple predicate chains
+     a predicate that is a comparison of a flag variable against
+     a constant.  */
+  tree_code cmp_code = find_var_cmp_const (m_preds, phi, &flag_def,
+					   &boundary_cst);
+  if (cmp_code == ERROR_MARK)
+    return true;
+
+  /* Now check all the uninit incoming edges have a constant flag
+     value that is in conflict with the use guard/predicate.  */
+  gphi *phi_def = as_a<gphi *> (flag_def);
+  bool all_pruned = prune_phi_opnds (phi, opnds, phi_def, boundary_cst,
+				     cmp_code, m_eval, visited,
+				     &visited_flag_phis);
+
+  if (visited_flag_phis)
+    BITMAP_FREE (visited_flag_phis);
+
+  return !all_pruned;
+}
+
+/* Return true if two predicates PRED1 and X2 are equivalent.  Assume
+   the expressions have already properly re-associated.  */
+
+static inline bool
+pred_equal_p (const pred_info &pred1, const pred_info &pred2)
+{
+  if (!operand_equal_p (pred1.pred_lhs, pred2.pred_lhs, 0)
+      || !operand_equal_p (pred1.pred_rhs, pred2.pred_rhs, 0))
+    return false;
+
+  tree_code c1 = pred1.cond_code, c2;
+  if (pred1.invert != pred2.invert
+      && TREE_CODE_CLASS (pred2.cond_code) == tcc_comparison)
+    c2 = invert_tree_comparison (pred2.cond_code, false);
+  else
+    c2 = pred2.cond_code;
+
+  return c1 == c2;
+}
+
+/* Return true if PRED tests inequality (i.e., X != Y).  */
+
+static inline bool
+is_neq_relop_p (const pred_info &pred)
+{
+
+  return ((pred.cond_code == NE_EXPR && !pred.invert)
+	  || (pred.cond_code == EQ_EXPR && pred.invert));
+}
+
+/* Returns true if PRED is of the form X != 0.  */
+
+static inline bool
+is_neq_zero_form_p (const pred_info &pred)
+{
+  if (!is_neq_relop_p (pred) || !integer_zerop (pred.pred_rhs)
+      || TREE_CODE (pred.pred_lhs) != SSA_NAME)
+    return false;
+  return true;
+}
+
+/* Return true if PRED is equivalent to X != 0.  */
+
+static inline bool
+pred_expr_equal_p (const pred_info &pred, tree expr)
+{
+  if (!is_neq_zero_form_p (pred))
+    return false;
+
+  return operand_equal_p (pred.pred_lhs, expr, 0);
+}
+
+/* Return true if VAL satisfies (x CMPC BOUNDARY) predicate.  CMPC can
+   be either one of the range comparison codes ({GE,LT,EQ,NE}_EXPR and
+   the like), or BIT_AND_EXPR.  EXACT_P is only meaningful for the latter.
+   Modify the question from VAL & BOUNDARY != 0 to VAL & BOUNDARY == VAL.
+   For other values of CMPC, EXACT_P is ignored.  */
+
+static bool
+value_sat_pred_p (tree val, tree boundary, tree_code cmpc,
+		  bool exact_p = false)
+{
+  if (cmpc != BIT_AND_EXPR)
+    return is_value_included_in (val, boundary, cmpc);
+
+  wide_int andw = wi::to_wide (val) & wi::to_wide (boundary);
+  if (exact_p)
+    return andw == wi::to_wide (val);
+
+  return andw.to_uhwi ();
+}
+
+/* Return true if the domain of single predicate expression PRED1
+   is a subset of that of PRED2, and false if it cannot be proved.  */
+
+static bool
+subset_of (const pred_info &pred1, const pred_info &pred2)
+{
+  if (pred_equal_p (pred1, pred2))
+    return true;
+
+  if ((TREE_CODE (pred1.pred_rhs) != INTEGER_CST)
+      || (TREE_CODE (pred2.pred_rhs) != INTEGER_CST))
+    return false;
+
+  if (!operand_equal_p (pred1.pred_lhs, pred2.pred_lhs, 0))
+    return false;
+
+  tree_code code1 = pred1.cond_code;
+  if (pred1.invert)
+    code1 = invert_tree_comparison (code1, false);
+  tree_code code2 = pred2.cond_code;
+  if (pred2.invert)
+    code2 = invert_tree_comparison (code2, false);
+
+  if (code2 == NE_EXPR && code1 == NE_EXPR)
+    return false;
+
+  if (code2 == NE_EXPR)
+    return !value_sat_pred_p (pred2.pred_rhs, pred1.pred_rhs, code1);
+
+  if (code1 == EQ_EXPR)
+    return value_sat_pred_p (pred1.pred_rhs, pred2.pred_rhs, code2);
+
+  if (code1 == code2)
+    return value_sat_pred_p (pred1.pred_rhs, pred2.pred_rhs, code2,
+			     code1 == BIT_AND_EXPR);
+
+  return false;
+}
+
+/* Return true if the domain of CHAIN1 is a subset of that of CHAIN2.
+   Return false if it cannot be proven so.  */
+
+static bool
+subset_of (const pred_chain &chain1, const pred_chain &chain2)
+{
+  unsigned np1 = chain1.length ();
+  unsigned np2 = chain2.length ();
+  for (unsigned i2 = 0; i2 < np2; i2++)
+    {
+      bool found = false;
+      const pred_info &info2 = chain2[i2];
+      for (unsigned i1 = 0; i1 < np1; i1++)
+	{
+	  const pred_info &info1 = chain1[i1];
+	  if (subset_of (info1, info2))
+	    {
+	      found = true;
+	      break;
+	    }
+	}
+      if (!found)
+	return false;
+    }
+  return true;
+}
+
+/* Return true if the domain defined by the predicate chain PREDS is
+   a subset of the domain of *THIS.  Return false if PREDS's domain
+   is not a subset of any of the sub-domains of *THIS (corresponding
+   to each individual chains in it), even though it may be still be
+   a subset of whole domain of *THIS which is the union (ORed) of all
+   its subdomains.  In other words, the result is conservative.  */
+
+bool
+predicate::includes (const pred_chain &chain) const
+{
+  for (unsigned i = 0; i < m_preds.length (); i++)
+    if (subset_of (chain, m_preds[i]))
+      return true;
+
+  return false;
+}
+
+/* Return true if the domain defined by *THIS is a superset of PREDS's
+   domain.
+   Avoid building generic trees (and rely on the folding capability
+   of the compiler), and instead perform brute force comparison of
+   individual predicate chains (this won't be a computationally costly
+   since the chains are pretty short).  Returning false does not
+   necessarily mean *THIS is not a superset of *PREDS, only that
+   it need not be since the analysis cannot prove it.  */
+
+bool
+predicate::superset_of (const predicate &preds) const
+{
+  for (unsigned i = 0; i < preds.m_preds.length (); i++)
+    if (!includes (preds.m_preds[i]))
+      return false;
+
+  return true;
+}
+
+/* Create a predicate of the form OP != 0 and push it the work list CHAIN.  */
+
+static void
+push_to_worklist (tree op, pred_chain *chain, hash_set<tree> *mark_set)
+{
+  if (mark_set->contains (op))
+    return;
+  mark_set->add (op);
+
+  pred_info arg_pred;
+  arg_pred.pred_lhs = op;
+  arg_pred.pred_rhs = integer_zero_node;
+  arg_pred.cond_code = NE_EXPR;
+  arg_pred.invert = false;
+  chain->safe_push (arg_pred);
+}
+
+/* Return a pred_info for a gimple assignment CMP_ASSIGN with comparison
+   rhs.  */
+
+static pred_info
+get_pred_info_from_cmp (const gimple *cmp_assign)
+{
+  pred_info pred;
+  pred.pred_lhs = gimple_assign_rhs1 (cmp_assign);
+  pred.pred_rhs = gimple_assign_rhs2 (cmp_assign);
+  pred.cond_code = gimple_assign_rhs_code (cmp_assign);
+  pred.invert = false;
+  return pred;
+}
+
+/* If PHI is a degenerate phi with all operands having the same value (relop)
+   update *PRED to that value and return true.  Otherwise return false.  */
+
+static bool
+is_degenerate_phi (gimple *phi, pred_info *pred)
+{
+  tree op0 = gimple_phi_arg_def (phi, 0);
+
+  if (TREE_CODE (op0) != SSA_NAME)
+    return false;
+
+  gimple *def0 = SSA_NAME_DEF_STMT (op0);
+  if (gimple_code (def0) != GIMPLE_ASSIGN)
+    return false;
+
+  if (TREE_CODE_CLASS (gimple_assign_rhs_code (def0)) != tcc_comparison)
+    return false;
+
+  pred_info pred0 = get_pred_info_from_cmp (def0);
+
+  unsigned n = gimple_phi_num_args (phi);
+  for (unsigned i = 1; i < n; ++i)
+    {
+      tree op = gimple_phi_arg_def (phi, i);
+      if (TREE_CODE (op) != SSA_NAME)
+	return false;
+
+      gimple *def = SSA_NAME_DEF_STMT (op);
+      if (gimple_code (def) != GIMPLE_ASSIGN)
+	return false;
+
+      if (TREE_CODE_CLASS (gimple_assign_rhs_code (def)) != tcc_comparison)
+	return false;
+
+      pred_info pred = get_pred_info_from_cmp (def);
+      if (!pred_equal_p (pred, pred0))
+	return false;
+    }
+
+  *pred = pred0;
+  return true;
+}
+
+/* Recursively compute the control dependence chains (paths of edges)
+   from the dependent basic block, DEP_BB, up to the dominating basic
+   block, DOM_BB (the head node of a chain should be dominated by it),
+   storing them in the CD_CHAINS array.
+   CUR_CD_CHAIN is the current chain being computed.
+   *NUM_CHAINS is total number of chains in the CD_CHAINS array.
+   *NUM_CALLS is the number of recursive calls to control unbounded
+   recursion.
+   Return true if the information is successfully computed, false if
+   there is no control dependence or not computed.  */
+
+static bool
+compute_control_dep_chain (basic_block dom_bb, const_basic_block dep_bb,
+			   vec<edge> cd_chains[], unsigned *num_chains,
+			   vec<edge> &cur_cd_chain, unsigned *num_calls,
+			   unsigned depth = 0)
+{
+  if (*num_calls > (unsigned)param_uninit_control_dep_attempts)
+    {
+      if (dump_file)
+	fprintf (dump_file, "param_uninit_control_dep_attempts exceeded: %u\n",
+		 *num_calls);
+      return false;
+    }
+  ++*num_calls;
+
+  /* FIXME: Use a set instead.  */
+  unsigned cur_chain_len = cur_cd_chain.length ();
+  if (cur_chain_len > MAX_CHAIN_LEN)
+    {
+      if (dump_file)
+	fprintf (dump_file, "MAX_CHAIN_LEN exceeded: %u\n", cur_chain_len);
+
+      return false;
+    }
+
+  if (cur_chain_len > 5)
+    {
+      if (dump_file)
+	fprintf (dump_file, "chain length exceeds 5: %u\n", cur_chain_len);
+    }
+
+  for (unsigned i = 0; i < cur_chain_len; i++)
+    {
+      edge e = cur_cd_chain[i];
+      /* Cycle detected.  */
+      if (e->src == dom_bb)
+	{
+	  if (dump_file)
+	    fprintf (dump_file, "cycle detected\n");
+	  return false;
+	}
+    }
+
+  if (DEBUG_PREDICATE_ANALYZER && dump_file)
+    fprintf (dump_file,
+	     "%*s%s (dom_bb = %u, dep_bb = %u, cd_chains = { %s }, ...)\n",
+	     depth, "", __func__, dom_bb->index, dep_bb->index,
+	     format_edge_vecs (cd_chains, *num_chains).c_str ());
+
+  bool found_cd_chain = false;
+
+  /* Iterate over DOM_BB's successors.  */
+  edge e;
+  edge_iterator ei;
+  FOR_EACH_EDGE (e, ei, dom_bb->succs)
+    {
+      int post_dom_check = 0;
+      if (e->flags & (EDGE_FAKE | EDGE_ABNORMAL))
+	continue;
+
+      basic_block cd_bb = e->dest;
+      cur_cd_chain.safe_push (e);
+      while (!is_non_loop_exit_postdominating (cd_bb, dom_bb))
+	{
+	  if (cd_bb == dep_bb)
+	    {
+	      /* Found a direct control dependence.  */
+	      if (*num_chains < MAX_NUM_CHAINS)
+		{
+		  cd_chains[*num_chains] = cur_cd_chain.copy ();
+		  (*num_chains)++;
+		}
+	      found_cd_chain = true;
+	      /* Check path from next edge.  */
+	      break;
+	    }
+
+	  /* Check if DEP_BB is indirectly control-dependent on DOM_BB.  */
+	  if (compute_control_dep_chain (cd_bb, dep_bb, cd_chains,
+					 num_chains, cur_cd_chain,
+					 num_calls, depth + 1))
+	    {
+	      found_cd_chain = true;
+	      break;
+	    }
+
+	  cd_bb = find_pdom (cd_bb);
+	  post_dom_check++;
+	  if (cd_bb == EXIT_BLOCK_PTR_FOR_FN (cfun)
+	      || post_dom_check > MAX_POSTDOM_CHECK)
+	    break;
+	}
+      cur_cd_chain.pop ();
+      gcc_assert (cur_cd_chain.length () == cur_chain_len);
+    }
+
+  gcc_assert (cur_cd_chain.length () == cur_chain_len);
+  return found_cd_chain;
+}
+
+/* Return true if PRED can be invalidated by any predicate in GUARD.  */
+
+static bool
+can_be_invalidated_p (const pred_info &pred, const pred_chain &guard)
+{
+  if (dump_file && dump_flags & TDF_DETAILS)
+    {
+      fprintf (dump_file, "Testing if predicate: ");
+      dump_pred_info (pred);
+      fprintf (dump_file, "\n...can be invalidated by a USE guard of: ");
+      dump_pred_chain (guard);
+      fputc ('\n', dump_file);
+    }
+
+  unsigned n = guard.length ();
+  for (unsigned i = 0; i < n; ++i)
+    {
+      if (pred_neg_p (pred, guard[i]))
+	{
+	  if (dump_file && dump_flags & TDF_DETAILS)
+	    {
+	      fprintf (dump_file, "  Predicate invalidated by: ");
+	      dump_pred_info (guard[i]);
+	      fputc ('\n', dump_file);
+	    }
+	  return true;
+	}
+    }
+
+  return false;
+}
+
+/* Return true if all predicates in PREDS are invalidated by GUARD being
+   true.  */
+
+static bool
+can_be_invalidated_p (const pred_chain_union &preds, const pred_chain &guard)
+{
+  if (preds.is_empty ())
+    return false;
+
+  if (dump_file && dump_flags & TDF_DETAILS)
+    dump_predicates (NULL, preds,
+		     "Testing if anything here can be invalidated: ");
+
+  for (unsigned i = 0; i < preds.length (); ++i)
+    {
+      const pred_chain &chain = preds[i];
+      for (unsigned j = 0; j < chain.length (); ++j)
+	if (can_be_invalidated_p (chain[j], guard))
+	  return true;
+
+      /* If we were unable to invalidate any predicate in C, then there
+	 is a viable path from entry to the PHI where the PHI takes
+	 an interesting value and continues to a use of the PHI.  */
+      return false;
+    }
+  return true;
+}
+
+/* Return true if none of the PHI arguments in OPNDS is used given
+   the use guards in *THIS that guard the PHI's use.  */
+
+bool
+predicate::use_cannot_happen (gphi *phi, unsigned opnds)
+{
+  if (!m_eval.phi_arg_set (phi))
+    return false;
+
+  /* PHI_USE_GUARDS are OR'ed together.  If we have more than one
+     possible guard, there's no way of knowing which guard was true.
+     Since we need to be absolutely sure that the uninitialized
+     operands will be invalidated, bail.  */
+  const pred_chain_union &phi_use_guards = m_preds;
+  if (phi_use_guards.length () != 1)
+    return false;
+
+  const pred_chain &use_guard = phi_use_guards[0];
+
+  /* Look for the control dependencies of all the interesting operands
+     and build guard predicates describing them.  */
+  unsigned n = gimple_phi_num_args (phi);
+  for (unsigned i = 0; i < n; ++i)
+    {
+      if (!MASK_TEST_BIT (opnds, i))
+	continue;
+
+      edge e = gimple_phi_arg_edge (phi, i);
+      auto_vec<edge> dep_chains[MAX_NUM_CHAINS];
+      auto_vec<edge, MAX_CHAIN_LEN + 1> cur_chain;
+      unsigned num_chains = 0;
+      unsigned num_calls = 0;
+
+      /* Build the control dependency chain for the PHI argument...  */
+      if (!compute_control_dep_chain (ENTRY_BLOCK_PTR_FOR_FN (cfun),
+				      e->src, dep_chains, &num_chains,
+				      cur_chain, &num_calls))
+	return false;
+
+      if (DEBUG_PREDICATE_ANALYZER && dump_file)
+	{
+	  fprintf (dump_file, "predicate::use_cannot_happen (...) "
+		   "dep_chains for arg %u:\n\t", i);
+	  dump_dep_chains (dep_chains, num_chains);
+	}
+
+      /* ...and convert it into a set of predicates guarding its
+	 definition.  */
+      predicate def_preds (m_eval);
+      def_preds.init_from_control_deps (dep_chains, num_chains);
+      if (def_preds.is_empty ())
+	/* If there's no predicate there's no basis to rule the use out.  */
+	return false;
+
+      def_preds.simplify ();
+      def_preds.normalize ();
+
+      /* Can the guard for this PHI argument be negated by the one
+	 guarding the PHI use?  */
+      if (!can_be_invalidated_p (def_preds.chain (), use_guard))
+	return false;
+    }
+
+  return true;
+}
+
+/* Implemented simplifications:
+
+   1) ((x IOR y) != 0) AND (x != 0) is equivalent to (x != 0);
+   2) (X AND Y) OR (!X AND Y) is equivalent to Y;
+   3) X OR (!X AND Y) is equivalent to (X OR Y);
+   4) ((x IAND y) != 0) || (x != 0 AND y != 0)) is equivalent to
+      (x != 0 AND y != 0)
+   5) (X AND Y) OR (!X AND Z) OR (!Y AND Z) is equivalent to
+      (X AND Y) OR Z
+
+   PREDS is the predicate chains, and N is the number of chains.  */
+
+/* Implement rule 1 above.  PREDS is the AND predicate to simplify
+   in place.  */
+
+static void
+simplify_1 (pred_chain &chain)
+{
+  bool simplified = false;
+  pred_chain s_chain = vNULL;
+
+  unsigned n = chain.length ();
+  for (unsigned i = 0; i < n; i++)
+    {
+      pred_info &a_pred = chain[i];
+
+      if (!a_pred.pred_lhs
+	  || !is_neq_zero_form_p (a_pred))
+	continue;
+
+      gimple *def_stmt = SSA_NAME_DEF_STMT (a_pred.pred_lhs);
+      if (gimple_code (def_stmt) != GIMPLE_ASSIGN)
+	continue;
+
+      if (gimple_assign_rhs_code (def_stmt) != BIT_IOR_EXPR)
+	continue;
+
+      for (unsigned j = 0; j < n; j++)
+	{
+	  const pred_info &b_pred = chain[j];
+
+	  if (!b_pred.pred_lhs
+	      || !is_neq_zero_form_p (b_pred))
+	    continue;
+
+	  if (pred_expr_equal_p (b_pred, gimple_assign_rhs1 (def_stmt))
+	      || pred_expr_equal_p (b_pred, gimple_assign_rhs2 (def_stmt)))
+	    {
+	      /* Mark A_PRED for removal from PREDS.  */
+	      a_pred.pred_lhs = NULL;
+	      a_pred.pred_rhs = NULL;
+	      simplified = true;
+	      break;
+	    }
+	}
+    }
+
+  if (!simplified)
+    return;
+
+  /* Remove predicates marked above.  */
+  for (unsigned i = 0; i < n; i++)
+    {
+      pred_info &a_pred = chain[i];
+      if (!a_pred.pred_lhs)
+	continue;
+      s_chain.safe_push (a_pred);
+    }
+
+  chain.release ();
+  chain = s_chain;
+}
+
+/* Implements rule 2 for the OR predicate PREDS:
+
+   2) (X AND Y) OR (!X AND Y) is equivalent to Y.  */
+
+bool
+predicate::simplify_2 ()
+{
+  bool simplified = false;
+
+  /* (X AND Y) OR (!X AND Y) is equivalent to Y.
+     (X AND Y) OR (X AND !Y) is equivalent to X.  */
+
+  unsigned n = m_preds.length ();
+  for (unsigned i = 0; i < n; i++)
+    {
+      pred_chain &a_chain = m_preds[i];
+      if (a_chain.length () != 2)
+	continue;
+
+      /* Create copies since the chain may be released below before
+	 the copy is added to the other chain.  */
+      const pred_info x = a_chain[0];
+      const pred_info y = a_chain[1];
+
+      for (unsigned j = 0; j < n; j++)
+	{
+	  if (j == i)
+	    continue;
+
+	  pred_chain &b_chain = m_preds[j];
+	  if (b_chain.length () != 2)
+	    continue;
+
+	  const pred_info &x2 = b_chain[0];
+	  const pred_info &y2 = b_chain[1];
+
+	  if (pred_equal_p (x, x2) && pred_neg_p (y, y2))
+	    {
+	      /* Kill a_chain.  */
+	      b_chain.release ();
+	      a_chain.release ();
+	      b_chain.safe_push (x);
+	      simplified = true;
+	      break;
+	    }
+	  if (pred_neg_p (x, x2) && pred_equal_p (y, y2))
+	    {
+	      /* Kill a_chain.  */
+	      a_chain.release ();
+	      b_chain.release ();
+	      b_chain.safe_push (y);
+	      simplified = true;
+	      break;
+	    }
+	}
+    }
+  /* Now clean up the chain.  */
+  if (simplified)
+    {
+      pred_chain_union s_preds = vNULL;
+      for (unsigned i = 0; i < n; i++)
+	{
+	  if (m_preds[i].is_empty ())
+	    continue;
+	  s_preds.safe_push (m_preds[i]);
+	}
+      m_preds.release ();
+      m_preds = s_preds;
+      s_preds = vNULL;
+    }
+
+  return simplified;
+}
+
+/* Implement rule 3 for the OR predicate PREDS:
+
+   3) x OR (!x AND y) is equivalent to x OR y.  */
+
+bool
+predicate::simplify_3 ()
+{
+  /* Now iteratively simplify X OR (!X AND Z ..)
+       into X OR (Z ...).  */
+
+  unsigned n = m_preds.length ();
+  if (n < 2)
+    return false;
+
+  bool simplified = false;
+  for (unsigned i = 0; i < n; i++)
+    {
+      const pred_chain &a_chain = m_preds[i];
+
+      if (a_chain.length () != 1)
+	continue;
+
+      const pred_info &x = a_chain[0];
+      for (unsigned j = 0; j < n; j++)
+	{
+	  if (j == i)
+	    continue;
+
+	  pred_chain b_chain = m_preds[j];
+	  if (b_chain.length () < 2)
+	    continue;
+
+	  for (unsigned k = 0; k < b_chain.length (); k++)
+	    {
+	      const pred_info &x2 = b_chain[k];
+	      if (pred_neg_p (x, x2))
+		{
+		  b_chain.unordered_remove (k);
+		  simplified = true;
+		  break;
+		}
+	    }
+	}
+    }
+  return simplified;
+}
+
+/* Implement rule 4 for the OR predicate PREDS:
+
+   2) ((x AND y) != 0) OR (x != 0 AND y != 0) is equivalent to
+       (x != 0 ANd y != 0).   */
+
+bool
+predicate::simplify_4 ()
+{
+  bool simplified = false;
+  pred_chain_union s_preds = vNULL;
+
+  unsigned n = m_preds.length ();
+  for (unsigned i = 0; i < n; i++)
+    {
+      pred_chain a_chain = m_preds[i];
+      if (a_chain.length () != 1)
+	continue;
+
+      const pred_info &z = a_chain[0];
+      if (!is_neq_zero_form_p (z))
+	continue;
+
+      gimple *def_stmt = SSA_NAME_DEF_STMT (z.pred_lhs);
+      if (gimple_code (def_stmt) != GIMPLE_ASSIGN)
+	continue;
+
+      if (gimple_assign_rhs_code (def_stmt) != BIT_AND_EXPR)
+	continue;
+
+      for (unsigned j = 0; j < n; j++)
+	{
+	  if (j == i)
+	    continue;
+
+	  pred_chain b_chain = m_preds[j];
+	  if (b_chain.length () != 2)
+	    continue;
+
+	  const pred_info &x2 = b_chain[0];
+	  const pred_info &y2 = b_chain[1];
+	  if (!is_neq_zero_form_p (x2) || !is_neq_zero_form_p (y2))
+	    continue;
+
+	  if ((pred_expr_equal_p (x2, gimple_assign_rhs1 (def_stmt))
+	       && pred_expr_equal_p (y2, gimple_assign_rhs2 (def_stmt)))
+	      || (pred_expr_equal_p (x2, gimple_assign_rhs2 (def_stmt))
+		  && pred_expr_equal_p (y2, gimple_assign_rhs1 (def_stmt))))
+	    {
+	      /* Kill a_chain.  */
+	      a_chain.release ();
+	      simplified = true;
+	      break;
+	    }
+	}
+    }
+  /* Now clean up the chain.  */
+  if (simplified)
+    {
+      for (unsigned i = 0; i < n; i++)
+	{
+	  if (m_preds[i].is_empty ())
+	    continue;
+	  s_preds.safe_push (m_preds[i]);
+	}
+
+      m_preds.release ();
+      m_preds = s_preds;
+      s_preds = vNULL;
+    }
+
+  return simplified;
+}
+
+/* Simplify predicates in *THIS.  */
+
+void
+predicate::simplify (gimple *use_or_def, bool is_use)
+{
+  if (dump_file && dump_flags & TDF_DETAILS)
+    {
+      fprintf (dump_file, "Before simplication ");
+      dump (use_or_def, is_use ? "[USE]:\n" : "[DEF]:\n");
+    }
+
+  unsigned n = m_preds.length ();
+  for (unsigned i = 0; i < n; i++)
+    ::simplify_1 (m_preds[i]);
+
+  if (n < 2)
+    return;
+
+  bool changed;
+  do
+    {
+      changed = false;
+      if (simplify_2 ())
+	changed = true;
+
+      if (simplify_3 ())
+	changed = true;
+
+      if (simplify_4 ())
+	changed = true;
+    }
+  while (changed);
+}
+
+/* Attempt to normalize predicate chains by following UD chains by
+   building up a big tree of either IOR operations or AND operations,
+   and converting the IOR tree into a pred_chain_union or the BIT_AND
+   tree into a pred_chain.
+   Example:
+
+  _3 = _2 RELOP1 _1;
+  _6 = _5 RELOP2 _4;
+  _9 = _8 RELOP3 _7;
+  _10 = _3 | _6;
+  _12 = _9 | _0;
+  _t = _10 | _12;
+
+  then _t != 0 will be normalized into a pred_chain_union
+
+   (_2 RELOP1 _1) OR (_5 RELOP2 _4) OR (_8 RELOP3 _7) OR (_0 != 0)
+
+   Similarly given:
+
+  _3 = _2 RELOP1 _1;
+  _6 = _5 RELOP2 _4;
+  _9 = _8 RELOP3 _7;
+  _10 = _3 & _6;
+  _12 = _9 & _0;
+
+  then _t != 0 will be normalized into a pred_chain:
+  (_2 RELOP1 _1) AND (_5 RELOP2 _4) AND (_8 RELOP3 _7) AND (_0 != 0)
+  */
+
+/* Store a PRED in *THIS.  */
+
+void
+predicate::push_pred (const pred_info &pred)
+{
+  pred_chain chain = vNULL;
+  chain.safe_push (pred);
+  m_preds.safe_push (chain);
+}
+
+/* Dump predicates in *THIS for STMT prepended by MSG.  */
+
+void
+predicate::dump (gimple *stmt, const char *msg) const
+{
+  fprintf (dump_file, "%s", msg);
+  if (stmt)
+    {
+      fputc ('\t', dump_file);
+      print_gimple_stmt (dump_file, stmt, 0);
+      fprintf (dump_file, "  is conditional on:\n");
+    }
+
+  unsigned np = m_preds.length ();
+  if (np == 0)
+    {
+      fprintf (dump_file, "\t(empty)\n");
+      return;
+    }
+
+  {
+    tree expr = build_pred_expr (m_preds);
+    char *str = print_generic_expr_to_str (expr);
+    fprintf (dump_file, "\t%s (expanded)\n", str);
+    free (str);
+  }
+
+  if (np > 1)
+    fprintf (dump_file, "\tOR (");
+  else
+    fputc ('\t', dump_file);
+  for (unsigned i = 0; i < np; i++)
+    {
+      dump_pred_chain (m_preds[i]);
+      if (i < np - 1)
+	fprintf (dump_file, ", ");
+      else if (i > 0)
+	fputc (')', dump_file);
+    }
+  fputc ('\n', dump_file);
+}
+
+/* Initialize *THIS with the predicates of the control dependence chains
+   between the basic block DEF_BB that defines a variable of interst and
+   USE_BB that uses the variable, respectively.  */
+
+predicate::predicate (basic_block def_bb, basic_block use_bb, func_t &eval)
+  : m_preds (vNULL), m_eval (eval)
+{
+  /* Set CD_ROOT to the basic block closest to USE_BB that is the control
+     equivalent of (is guarded by the same predicate as) DEF_BB that also
+     dominates USE_BB.  */
+  basic_block cd_root = def_bb;
+  while (dominated_by_p (CDI_DOMINATORS, use_bb, cd_root))
+    {
+      /* Find CD_ROOT's closest postdominator that's its control
+	 equivalent.  */
+      if (basic_block bb = find_control_equiv_block (cd_root))
+	if (dominated_by_p (CDI_DOMINATORS, use_bb, bb))
+	  {
+	    cd_root = bb;
+	    continue;
+	  }
+
+      break;
+    }
+
+  /* Set DEP_CHAINS to the set of edges between CD_ROOT and USE_BB.
+     Each DEP_CHAINS element is a series of edges whose conditions
+     are logical conjunctions.  Together, the DEP_CHAINS vector is
+     used below to initialize an OR expression of the conjunctions.  */
+  unsigned num_calls = 0;
+  unsigned num_chains = 0;
+  auto_vec<edge> dep_chains[MAX_NUM_CHAINS];
+  auto_vec<edge, MAX_CHAIN_LEN + 1> cur_chain;
+
+  compute_control_dep_chain (cd_root, use_bb, dep_chains, &num_chains,
+			     cur_chain, &num_calls);
+
+  if (DEBUG_PREDICATE_ANALYZER && dump_file)
+    {
+      fprintf (dump_file, "predicate::predicate (def_bb = %u, use_bb = %u, func_t) "
+	       "initialized from %u dep_chains:\n\t",
+	       def_bb->index, use_bb->index, num_chains);
+      dump_dep_chains (dep_chains, num_chains);
+    }
+
+  /* From the set of edges computed above initialize *THIS as the OR
+     condition under which the definition in DEF_BB is used in USE_BB.
+     Each OR subexpression is represented by one element of DEP_CHAINS,
+     where each element consists of a series of AND subexpressions.  */
+  init_from_control_deps (dep_chains, num_chains);
+}
+
+/* Release resources in *THIS.  */
+
+predicate::~predicate ()
+{
+  unsigned n = m_preds.length ();
+  for (unsigned i = 0; i != n; ++i)
+    m_preds[i].release ();
+  m_preds.release ();
+}
+
+/* Copy-assign RHS to *THIS.  */
+
+predicate&
+predicate::operator= (const predicate &rhs)
+{
+  if (this == &rhs)
+    return *this;
+
+  /* FIXME: Make this a compile-time constraint?  */
+  gcc_assert (&m_eval == &rhs.m_eval);
+
+  unsigned n = m_preds.length ();
+  for (unsigned i = 0; i != n; ++i)
+    m_preds[i].release ();
+  m_preds.release ();
+
+  n = rhs.m_preds.length ();
+  for (unsigned i = 0; i != n; ++i)
+    {
+      const pred_chain &chain = rhs.m_preds[i];
+      m_preds.safe_push (chain.copy ());
+    }
+
+  return *this;
+}
+
+/* For each use edge of PHI, compute all control dependence chains
+   and convert those to the composite predicates in M_PREDS.
+   Return true if a nonempty predicate has been obtained.  */
+
+bool
+predicate::init_from_phi_def (gphi *phi)
+{
+  gcc_assert (is_empty ());
+
+  basic_block phi_bb = gimple_bb (phi);
+  /* Find the closest dominating bb to be the control dependence root.  */
+  basic_block cd_root = find_dom (phi_bb);
+  if (!cd_root)
+    return false;
+
+  /* Set DEF_EDGES to the edges to the PHI from the bb's that provide
+     definitions of each of the PHI operands for which M_EVAL is false.  */
+  auto_vec<edge> def_edges;
+  hash_set<gimple *> visited_phis;
+  collect_phi_def_edges (phi, cd_root, &def_edges, m_eval, &visited_phis);
+
+  unsigned nedges = def_edges.length ();
+  if (nedges == 0)
+    return false;
+
+  unsigned num_chains = 0;
+  auto_vec<edge> dep_chains[MAX_NUM_CHAINS];
+  auto_vec<edge, MAX_CHAIN_LEN + 1> cur_chain;
+  for (unsigned i = 0; i < nedges; i++)
+    {
+      edge e = def_edges[i];
+      unsigned num_calls = 0;
+      unsigned prev_nc = num_chains;
+      compute_control_dep_chain (cd_root, e->src, dep_chains,
+				 &num_chains, cur_chain, &num_calls);
+
+      /* Update the newly added chains with the phi operand edge.  */
+      if (EDGE_COUNT (e->src->succs) > 1)
+	{
+	  if (prev_nc == num_chains && num_chains < MAX_NUM_CHAINS)
+	    dep_chains[num_chains++] = vNULL;
+	  for (unsigned j = prev_nc; j < num_chains; j++)
+	    dep_chains[j].safe_push (e);
+	}
+    }
+
+  /* Convert control dependence chains to the predicate in *THIS under
+     which the PHI operands are defined to values for which M_EVAL is
+     false.  */
+  init_from_control_deps (dep_chains, num_chains);
+  return !is_empty ();
+}
+
+/* Compute the predicates that guard the use USE_STMT and check if
+   the incoming paths that have an empty (or possibly empty) definition
+   can be pruned.  Return true if it can be determined that the use of
+   PHI's def in USE_STMT is guarded by a predicate set that does not
+   overlap with the predicate sets of all runtime paths that do not
+   have a definition.
+
+   Return false if the use is not guarded or if it cannot be determined.
+   USE_BB is the bb of the use (for phi operand use, the bb is not the bb
+   of the phi stmt, but the source bb of the operand edge).
+
+   OPNDS is a bitmap with a bit set for each PHI operand of interest.
+
+   THIS->M_PREDS contains the (memoized) defining predicate chains of
+   a PHI.  If THIS->M_PREDS is empty, the PHI's defining predicate
+   chains are computed and stored into THIS->M_PREDS as needed.
+
+   VISITED_PHIS is a pointer set of phis being visited.  */
+
+bool
+predicate::is_use_guarded (gimple *use_stmt, basic_block use_bb,
+			   gphi *phi, unsigned opnds,
+			   hash_set<gphi *> *visited)
+{
+  if (visited->add (phi))
+    return false;
+
+  /* The basic block where the PHI is defined.  */
+  basic_block def_bb = gimple_bb (phi);
+
+  /* Try to build the predicate expression under which the PHI flows
+     into its use.  This will be empty if the PHI is defined and used
+     in the same bb.  */
+  predicate use_preds (def_bb, use_bb, m_eval);
+
+  if (is_non_loop_exit_postdominating (use_bb, def_bb))
+    {
+      if (is_empty ())
+	{
+	  /* Lazily initialize *THIS from the PHI and build its use
+	     expression.  */
+	  init_from_phi_def (phi);
+	  m_use_expr = build_pred_expr (use_preds.m_preds);
+	}
+
+      /* The use is not guarded.  */
+      return false;
+    }
+
+  if (use_preds.is_empty ())
+    return false;
+
+  /* Try to prune the dead incoming phi edges.  */
+  if (!use_preds.overlap (phi, opnds, visited))
+    {
+      if (DEBUG_PREDICATE_ANALYZER && dump_file)
+	fputs ("found predicate overlap\n", dump_file);
+
+      return true;
+    }
+
+  /* We might be able to prove that if the control dependencies for OPNDS
+     are true, the control dependencies for USE_STMT can never be true.  */
+  if (use_preds.use_cannot_happen (phi, opnds))
+    return true;
+
+  if (is_empty ())
+    {
+      /* Lazily initialize *THIS from PHI.  */
+      if (!init_from_phi_def (phi))
+	{
+	  m_use_expr = build_pred_expr (use_preds.m_preds);
+	  return false;
+	}
+
+      simplify (phi);
+      normalize (phi);
+    }
+
+  use_preds.simplify (use_stmt, /*is_use=*/true);
+  use_preds.normalize (use_stmt, /*is_use=*/true);
+
+  /* Return true if the predicate guarding the valid definition (i.e.,
+     *THIS) is a superset of the predicate guarding the use (i.e.,
+     USE_PREDS).  */
+  if (superset_of (use_preds))
+    return true;
+
+  m_use_expr = build_pred_expr (use_preds.m_preds);
+
+  return false;
+}
+
+/* Public interface to the above. */
+
+bool
+predicate::is_use_guarded (gimple *stmt, basic_block use_bb, gphi *phi,
+			   unsigned opnds)
+{
+  hash_set<gphi *> visited;
+  return is_use_guarded (stmt, use_bb, phi, opnds, &visited);
+}
+
+/* Normalize predicate PRED:
+   1) if PRED can no longer be normalized, append it to *THIS.
+   2) otherwise if PRED is of the form x != 0, follow x's definition
+      and put normalized predicates into WORK_LIST.  */
+
+void
+predicate::normalize (pred_chain *norm_chain,
+		      pred_info pred,
+		      tree_code and_or_code,
+		      pred_chain *work_list,
+		      hash_set<tree> *mark_set)
+{
+  if (!is_neq_zero_form_p (pred))
+    {
+      if (and_or_code == BIT_IOR_EXPR)
+	push_pred (pred);
+      else
+	norm_chain->safe_push (pred);
+      return;
+    }
+
+  gimple *def_stmt = SSA_NAME_DEF_STMT (pred.pred_lhs);
+
+  if (gimple_code (def_stmt) == GIMPLE_PHI
+      && is_degenerate_phi (def_stmt, &pred))
+    /* PRED has been modified above.  */
+    work_list->safe_push (pred);
+  else if (gimple_code (def_stmt) == GIMPLE_PHI && and_or_code == BIT_IOR_EXPR)
+    {
+      unsigned n = gimple_phi_num_args (def_stmt);
+
+      /* Punt for a nonzero constant.  The predicate should be one guarding
+	 the phi edge.  */
+      for (unsigned i = 0; i < n; ++i)
+	{
+	  tree op = gimple_phi_arg_def (def_stmt, i);
+	  if (TREE_CODE (op) == INTEGER_CST && !integer_zerop (op))
+	    {
+	      push_pred (pred);
+	      return;
+	    }
+	}
+
+      for (unsigned i = 0; i < n; ++i)
+	{
+	  tree op = gimple_phi_arg_def (def_stmt, i);
+	  if (integer_zerop (op))
+	    continue;
+
+	  push_to_worklist (op, work_list, mark_set);
+	}
+    }
+  else if (gimple_code (def_stmt) != GIMPLE_ASSIGN)
+    {
+      if (and_or_code == BIT_IOR_EXPR)
+	push_pred (pred);
+      else
+	norm_chain->safe_push (pred);
+    }
+  else if (gimple_assign_rhs_code (def_stmt) == and_or_code)
+    {
+      /* Avoid splitting up bit manipulations like x & 3 or y | 1.  */
+      if (is_gimple_min_invariant (gimple_assign_rhs2 (def_stmt)))
+	{
+	  /* But treat x & 3 as a condition.  */
+	  if (and_or_code == BIT_AND_EXPR)
+	    {
+	      pred_info n_pred;
+	      n_pred.pred_lhs = gimple_assign_rhs1 (def_stmt);
+	      n_pred.pred_rhs = gimple_assign_rhs2 (def_stmt);
+	      n_pred.cond_code = and_or_code;
+	      n_pred.invert = false;
+	      norm_chain->safe_push (n_pred);
+	    }
+	}
+      else
+	{
+	  push_to_worklist (gimple_assign_rhs1 (def_stmt), work_list, mark_set);
+	  push_to_worklist (gimple_assign_rhs2 (def_stmt), work_list, mark_set);
+	}
+    }
+  else if (TREE_CODE_CLASS (gimple_assign_rhs_code (def_stmt))
+	   == tcc_comparison)
+    {
+      pred_info n_pred = get_pred_info_from_cmp (def_stmt);
+      if (and_or_code == BIT_IOR_EXPR)
+	push_pred (n_pred);
+      else
+	norm_chain->safe_push (n_pred);
+    }
+  else
+    {
+      if (and_or_code == BIT_IOR_EXPR)
+	push_pred (pred);
+      else
+	norm_chain->safe_push (pred);
+    }
+}
+
+/* Normalize PRED and store the normalized predicates in THIS->M_PREDS.  */
+
+void
+predicate::normalize (const pred_info &pred)
+{
+  if (!is_neq_zero_form_p (pred))
+    {
+      push_pred (pred);
+      return;
+    }
+
+  tree_code and_or_code = ERROR_MARK;
+
+  gimple *def_stmt = SSA_NAME_DEF_STMT (pred.pred_lhs);
+  if (gimple_code (def_stmt) == GIMPLE_ASSIGN)
+    and_or_code = gimple_assign_rhs_code (def_stmt);
+  if (and_or_code != BIT_IOR_EXPR && and_or_code != BIT_AND_EXPR)
+    {
+      if (TREE_CODE_CLASS (and_or_code) == tcc_comparison)
+	{
+	  pred_info n_pred = get_pred_info_from_cmp (def_stmt);
+	  push_pred (n_pred);
+	}
+      else
+	push_pred (pred);
+      return;
+    }
+
+
+  pred_chain norm_chain = vNULL;
+  pred_chain work_list = vNULL;
+  work_list.safe_push (pred);
+  hash_set<tree> mark_set;
+
+  while (!work_list.is_empty ())
+    {
+      pred_info a_pred = work_list.pop ();
+      normalize (&norm_chain, a_pred, and_or_code, &work_list, &mark_set);
+    }
+
+  if (and_or_code == BIT_AND_EXPR)
+    m_preds.safe_push (norm_chain);
+
+  work_list.release ();
+}
+
+/* Normalize a single predicate PRED_CHAIN and append it to *THIS.  */
+
+void
+predicate::normalize (const pred_chain &chain)
+{
+  pred_chain work_list = vNULL;
+  hash_set<tree> mark_set;
+  for (unsigned i = 0; i < chain.length (); i++)
+    {
+      work_list.safe_push (chain[i]);
+      mark_set.add (chain[i].pred_lhs);
+    }
+
+  /* Normalized chain of predicates built up below.  */
+  pred_chain norm_chain = vNULL;
+  while (!work_list.is_empty ())
+    {
+      pred_info pi = work_list.pop ();
+      predicate pred (m_eval);
+      /* The predicate object is not modified here, only NORM_CHAIN and
+	 WORK_LIST are appended to.  */
+      pred.normalize (&norm_chain, pi, BIT_AND_EXPR, &work_list, &mark_set);
+    }
+
+  m_preds.safe_push (norm_chain);
+  work_list.release ();
+}
+
+/* Normalize predicate chains in THIS.  */
+
+void
+predicate::normalize (gimple *use_or_def, bool is_use)
+{
+  if (dump_file && dump_flags & TDF_DETAILS)
+    {
+      fprintf (dump_file, "Before normalization ");
+      dump (use_or_def, is_use ? "[USE]:\n" : "[DEF]:\n");
+    }
+
+  predicate norm_preds (m_eval);
+  for (unsigned i = 0; i < m_preds.length (); i++)
+    {
+      if (m_preds[i].length () != 1)
+	norm_preds.normalize (m_preds[i]);
+      else
+	norm_preds.normalize (m_preds[i][0]);
+    }
+
+  *this = norm_preds;
+
+  if (dump_file)
+    {
+      fprintf (dump_file, "After normalization ");
+      dump (use_or_def, is_use ? "[USE]:\n" : "[DEF]:\n");
+    }
+}
+
+/* Add a predicate for the condition or logical assignment STMT to CHAIN.
+   Expand SSA_NAME into constituent subexpressions.  Invert the result
+   if INVERT is true.  Return true if the predicate has been added.  */
+
+static bool
+add_pred (pred_chain *chain, gimple *stmt, bool invert)
+{
+  if (gimple_code (stmt) == GIMPLE_COND)
+    {
+      tree lhs = gimple_cond_lhs (stmt);
+      if (TREE_CODE (lhs) == SSA_NAME)
+	{
+	  gimple *def = SSA_NAME_DEF_STMT (lhs);
+	  if (is_gimple_assign (def)
+	      && add_pred (chain, def, invert))
+	    return true;
+	}
+
+      pred_info pred;
+      pred.pred_lhs = lhs;
+      pred.pred_rhs = gimple_cond_rhs (stmt);
+      pred.cond_code = gimple_cond_code (stmt);
+      pred.invert = invert;
+      chain->safe_push (pred);
+      return true;
+    }
+
+  if (!is_gimple_assign (stmt))
+    return false;
+
+  if (gimple_assign_single_p (stmt))
+    // FIXME: handle this?
+    return false;
+
+  if (TREE_TYPE (gimple_assign_lhs (stmt)) != boolean_type_node)
+    return false;
+
+  tree rhs1 = gimple_assign_rhs1 (stmt);
+  tree rhs2 = gimple_assign_rhs2 (stmt);
+  tree_code code = gimple_assign_rhs_code (stmt);
+  if (code == BIT_AND_EXPR)
+    {
+      if (TREE_CODE (rhs1) == SSA_NAME
+	  && add_pred (chain, SSA_NAME_DEF_STMT (rhs1), invert)
+	  && TREE_CODE (rhs2) == SSA_NAME
+	  /* FIXME: Need to handle failure below! */
+	  && add_pred (chain, SSA_NAME_DEF_STMT (rhs2), invert))
+	return true;
+    }
+  else if (TREE_CODE_CLASS (code) != tcc_comparison)
+    return false;
+
+  pred_info pred;
+  pred.pred_lhs = rhs1;
+  pred.pred_rhs = rhs2;
+  pred.cond_code = code;
+  pred.invert = invert;
+  chain->safe_push (pred);
+  return true;
+}
+
+/* Convert the chains of control dependence edges into a set of predicates.
+   A control dependence chain is represented by a vector edges.  DEP_CHAINS
+   points to an array of NUM_CHAINS dependence chains. One edge in
+   a dependence chain is mapped to predicate expression represented by
+   pred_info type.  One dependence chain is converted to a composite
+   predicate that is the result of AND operation of pred_info mapped to
+   each edge.  A composite predicate is represented by a vector of
+   pred_info.  Sets M_PREDS to the resulting composite predicates.  */
+
+void
+predicate::init_from_control_deps (const vec<edge> *dep_chains,
+				   unsigned num_chains)
+{
+  gcc_assert (is_empty ());
+
+  bool has_valid_pred = false;
+  if (num_chains == 0)
+    return;
+
+  if (num_chains >= MAX_NUM_CHAINS)
+    {
+      if (dump_file)
+	fprintf (dump_file, "MAX_NUM_CHAINS exceeded: %u\n", num_chains);
+      return;
+    }
+
+  /* Convert the control dependency chain into a set of predicates.  */
+  m_preds.reserve (num_chains);
+
+  for (unsigned i = 0; i < num_chains; i++)
+    {
+      /* One path through the CFG represents a logical conjunction
+	 of the predicates.  */
+      const vec<edge> &path = dep_chains[i];
+
+      has_valid_pred = false;
+      /* The chain of predicates guarding the definition along this path.  */
+      pred_chain t_chain{ };
+      for (unsigned j = 0; j < path.length (); j++)
+	{
+	  edge e = path[j];
+	  basic_block guard_bb = e->src;
+	  /* Ignore empty forwarder blocks.  */
+	  if (empty_block_p (guard_bb) && single_succ_p (guard_bb))
+	    continue;
+
+	  /* An empty basic block here is likely a PHI, and is not one
+	     of the cases we handle below.  */
+	  gimple_stmt_iterator gsi = gsi_last_bb (guard_bb);
+	  if (gsi_end_p (gsi))
+	    {
+	      has_valid_pred = false;
+	      break;
+	    }
+	  /* Get the conditional controlling the bb exit edge.  */
+	  gimple *cond_stmt = gsi_stmt (gsi);
+	  if (is_gimple_call (cond_stmt) && EDGE_COUNT (e->src->succs) >= 2)
+	    /* Ignore EH edge.  Can add assertion on the other edge's flag.  */
+	    continue;
+	  /* Skip if there is essentially one succesor.  */
+	  if (EDGE_COUNT (e->src->succs) == 2)
+	    {
+	      edge e1;
+	      edge_iterator ei1;
+	      bool skip = false;
+
+	      FOR_EACH_EDGE (e1, ei1, e->src->succs)
+		{
+		  if (EDGE_COUNT (e1->dest->succs) == 0)
+		    {
+		      skip = true;
+		      break;
+		    }
+		}
+	      if (skip)
+		continue;
+	    }
+	  if (gimple_code (cond_stmt) == GIMPLE_COND)
+	    {
+	      /* The true edge corresponds to the uninteresting condition.
+		 Add the negated predicate(s) for the edge to record
+		 the interesting condition.  */
+	      pred_info one_pred;
+	      one_pred.pred_lhs = gimple_cond_lhs (cond_stmt);
+	      one_pred.pred_rhs = gimple_cond_rhs (cond_stmt);
+	      one_pred.cond_code = gimple_cond_code (cond_stmt);
+	      one_pred.invert = !!(e->flags & EDGE_FALSE_VALUE);
+
+	      t_chain.safe_push (one_pred);
+
+	      if (DEBUG_PREDICATE_ANALYZER && dump_file)
+		{
+		  fprintf (dump_file, "one_pred = ");
+		  dump_pred_info (one_pred);
+		  fputc ('\n', dump_file);
+		}
+
+	      has_valid_pred = true;
+	    }
+	  else if (gswitch *gs = dyn_cast<gswitch *> (cond_stmt))
+	    {
+	      /* Avoid quadratic behavior.  */
+	      if (gimple_switch_num_labels (gs) > MAX_SWITCH_CASES)
+		{
+		  has_valid_pred = false;
+		  break;
+		}
+	      /* Find the case label.  */
+	      tree l = NULL_TREE;
+	      unsigned idx;
+	      for (idx = 0; idx < gimple_switch_num_labels (gs); ++idx)
+		{
+		  tree tl = gimple_switch_label (gs, idx);
+		  if (e->dest == label_to_block (cfun, CASE_LABEL (tl)))
+		    {
+		      if (!l)
+			l = tl;
+		      else
+			{
+			  l = NULL_TREE;
+			  break;
+			}
+		    }
+		}
+	      /* If more than one label reaches this block or the case
+		 label doesn't have a single value (like the default one)
+		 fail.  */
+	      if (!l
+		  || !CASE_LOW (l)
+		  || (CASE_HIGH (l)
+		      && !operand_equal_p (CASE_LOW (l), CASE_HIGH (l), 0)))
+		{
+		  has_valid_pred = false;
+		  break;
+		}
+
+	      pred_info one_pred;
+	      one_pred.pred_lhs = gimple_switch_index (gs);
+	      one_pred.pred_rhs = CASE_LOW (l);
+	      one_pred.cond_code = EQ_EXPR;
+	      one_pred.invert = false;
+	      t_chain.safe_push (one_pred);
+	      has_valid_pred = true;
+	    }
+	  else
+	    {
+	      /* Disabled.  See PR 90994.
+		 has_valid_pred = false;  */
+	      break;
+	    }
+	}
+
+      if (!has_valid_pred)
+	break;
+      else
+	m_preds.safe_push (t_chain);
+    }
+
+  if (DEBUG_PREDICATE_ANALYZER && dump_file)
+    {
+      fprintf (dump_file, "init_from_control_deps {%s}:\n",
+	       format_edge_vecs (dep_chains, num_chains).c_str ());
+      dump (NULL, "");
+    }
+
+  gcc_assert (has_valid_pred == (m_preds.length () > 0));
+}
+
+/* Return the predicate expression guarding the definition of
+   the interesting variable.  When INVERT is set, return the logical
+   NOT of the predicate.  */
+
+tree
+predicate::def_expr (bool invert /* = false */) const
+{
+  /* The predicate is stored in an inverted form.  */
+  return build_pred_expr (m_preds, !invert);
+}
+
+/* Return the predicate expression guarding the use of the interesting
+   variable or null if the use predicate hasn't been determined yet.  */
+
+tree
+predicate::use_expr () const
+{
+  return m_use_expr;
+}
+
+/* Return a logical AND expression with the (optionally inverted) predicate
+   expression guarding the definition of the interesting variable and one
+   guarding its use.  Return null if the use predicate hasn't yet been
+   determined.  */
+
+tree
+predicate::expr (bool invert /* = false */) const
+{
+  if (!m_use_expr)
+    return NULL_TREE;
+
+  tree expr = build_pred_expr (m_preds, !invert);
+  return build2 (TRUTH_AND_EXPR, boolean_type_node, expr, m_use_expr);
+}
diff --git a/gcc/gimple-predicate-analysis.h b/gcc/gimple-predicate-analysis.h
new file mode 100644
index 00000000000..82fd3dae15b
--- /dev/null
+++ b/gcc/gimple-predicate-analysis.h
@@ -0,0 +1,158 @@ 
+/* Support for simple predicate analysis.
+
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   Contributed by Martin Sebor <msebor@redhat.com>
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GCC is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef GIMPLE_PREDICATE_ANALYSIS_H_INCLUDED
+#define GIMPLE_PREDICATE_ANALYSIS_H_INCLUDED
+
+#define MAX_NUM_CHAINS 8
+#define MAX_CHAIN_LEN 5
+#define MAX_POSTDOM_CHECK 8
+#define MAX_SWITCH_CASES 40
+
+/* Represents a simple Boolean predicate.  */
+struct pred_info
+{
+  tree pred_lhs;
+  tree pred_rhs;
+  enum tree_code cond_code;
+  bool invert;
+};
+
+/* The type to represent a sequence of predicates grouped
+   with .AND. operation.  */
+typedef vec<pred_info, va_heap, vl_ptr> pred_chain;
+
+/* The type to represent a sequence of pred_chains grouped
+   with .OR. operation.  */
+typedef vec<pred_chain, va_heap, vl_ptr> pred_chain_union;
+
+/* Represents a complex Boolean predicate expression.  */
+class predicate
+{
+ public:
+  /* Base function object type used to determine whether an expression
+     is of interest.  */
+  struct func_t
+  {
+    typedef unsigned phi_arg_set_t;
+
+    /* Return true if the argument is an expression of interest.  */
+    virtual bool operator()(tree) = 0;
+    /* Return a bitset of PHI arguments of interest.  By default returns
+       bitset with a bit set for each argument.  Should be called in
+       the overriden function first and, if nonzero, the result then
+       refined as appropriate.  */
+    virtual phi_arg_set_t phi_arg_set (gphi *);
+
+    /* Maximum number of PHI arguments supported by phi_arg_set().  */
+    static constexpr unsigned max_phi_args =
+      sizeof (phi_arg_set_t) * CHAR_BIT;
+  };
+
+  /* Construct with the specified EVAL object.  */
+  predicate (func_t &eval)
+    : m_preds (vNULL), m_eval (eval), m_use_expr () { }
+
+  /* Copy.  */
+  predicate (const predicate &rhs)
+    : m_preds (vNULL), m_eval (rhs.m_eval), m_use_expr ()
+    {
+      *this = rhs;
+    }
+
+  predicate (basic_block, basic_block, func_t &);
+
+  ~predicate ();
+
+  /* Assign.  */
+  predicate& operator= (const predicate &);
+
+  bool is_empty () const
+  {
+    return m_preds.is_empty ();
+  }
+
+  const pred_chain_union chain () const
+  {
+    return m_preds;
+  }
+
+  /* Return true if the use by a statement in the basic block of
+     a PHI operand is ruled out (i.e., guarded) by *THIS.  */
+  bool is_use_guarded (gimple *, basic_block, gphi *, unsigned);
+
+  void init_from_control_deps (const vec<edge> *, unsigned);
+
+  void dump (gimple *, const char *) const;
+
+  void normalize (gimple * = NULL, bool = false);
+  void simplify (gimple * = NULL, bool = false);
+
+  bool is_use_guarded (gimple *, basic_block, gphi *, unsigned,
+		       hash_set<gphi *> *);
+
+  /* Return the predicate expression guarding the definition of
+     the interesting variable, optionally inverted.  */
+  tree def_expr (bool = false) const;
+  /* Return the predicate expression guarding the use of the interesting
+     variable.  */
+  tree use_expr () const;
+
+  tree expr (bool = false) const;
+
+private:
+  bool includes (const pred_chain &) const;
+  bool superset_of (const predicate &) const;
+  bool overlap (gphi *, unsigned, hash_set<gphi *> *);
+  bool use_cannot_happen (gphi *, unsigned);
+
+  bool init_from_phi_def (gphi *);
+
+  void push_pred (const pred_info &);
+
+  /* Normalization functions.  */
+  void normalize (pred_chain *, pred_info, tree_code, pred_chain *,
+		  hash_set<tree> *);
+
+  void normalize (const pred_info &);
+  void normalize (const pred_chain &);
+
+  /* Simplification functions.  */
+  bool simplify_2 ();
+  bool simplify_3 ();
+  bool simplify_4 ();
+
+private:
+  /* Representation of the predicate expression(s).  */
+  pred_chain_union m_preds;
+  /* Callback to evaluate an operand.  Return true if it's interesting.  */
+  func_t &m_eval;
+  /* The predicate expression guarding the use of the interesting
+     variable.  */
+  tree m_use_expr;
+};
+
+/* Bit mask handling macros.  */
+#define MASK_SET_BIT(mask, pos) mask |= (1 << pos)
+#define MASK_TEST_BIT(mask, pos) (mask & (1 << pos))
+#define MASK_EMPTY(mask) (mask == 0)
+
+#endif // GIMPLE_PREDICATE_ANALYSIS_H_INCLUDED
diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c
index 394dbf40c9c..646875c90d3 100644
--- a/gcc/tree-ssa-uninit.c
+++ b/gcc/tree-ssa-uninit.c
@@ -39,6 +39,8 @@  along with GCC; see the file COPYING3.  If not see
 #include "calls.h"
 #include "gimple-range.h"
 
+#include "gimple-predicate-analysis.h"
+
 /* This implements the pass that does predicate aware warning on uses of
    possibly uninitialized variables.  The pass first collects the set of
    possibly uninitialized SSA names.  For each such name, it walks through
@@ -49,19 +51,11 @@  along with GCC; see the file COPYING3.  If not see
    default definitions or by checking if the predicate set that guards the
    defining paths is a superset of the use predicate.  */
 
-/* Max PHI args we can handle in pass.  */
-const unsigned max_phi_args = 32;
-
 /* Pointer set of potentially undefined ssa names, i.e.,
    ssa names that are defined by phi with operands that
    are not defined or potentially undefined.  */
 static hash_set<tree> *possibly_undefined_names = 0;
 
-/* Bit mask handling macros.  */
-#define MASK_SET_BIT(mask, pos) mask |= (1 << pos)
-#define MASK_TEST_BIT(mask, pos) (mask & (1 << pos))
-#define MASK_EMPTY(mask) (mask == 0)
-
 /* Returns the first bit position (starting from LSB)
    in mask that is non zero.  Returns -1 if the mask is empty.  */
 static int
@@ -355,23 +342,24 @@  check_defs (ao_ref *ref, tree vdef, void *data_)
   /* The ASAN_MARK intrinsic doesn't modify the variable.  */
   if (is_gimple_call (def_stmt))
     {
+      /* The ASAN_MARK intrinsic doesn't modify the variable.  */
       if (gimple_call_internal_p (def_stmt)
 	  && gimple_call_internal_fn (def_stmt) == IFN_ASAN_MARK)
-       return false;
+	return false;
 
       if (tree fndecl = gimple_call_fndecl (def_stmt))
-       {
-	 /* Some sanitizer calls pass integer arguments to built-ins
-	    that expect pointers.  Avoid using gimple_call_builtin_p()
-	    which fails for such calls.  */
-	 if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
-	   {
-	     built_in_function fncode = DECL_FUNCTION_CODE (fndecl);
-	     if (fncode > BEGIN_SANITIZER_BUILTINS
-		 && fncode < END_SANITIZER_BUILTINS)
-	       return false;
-	   }
-       }
+	{
+	  /* Some sanitizer calls pass integer arguments to built-ins
+	     that expect pointets. Avoid using gimple_call_builtin_p()
+	     which fails for such calls.  */
+	  if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+	    {
+	      built_in_function fncode = DECL_FUNCTION_CODE (fndecl);
+	      if (fncode > BEGIN_SANITIZER_BUILTINS
+		  && fncode < END_SANITIZER_BUILTINS)
+		return false;
+	    }
+	}
     }
 
   /* End of VLA scope is not a kill.  */
@@ -957,8 +945,8 @@  can_skip_redundant_opnd (tree opnd, gimple *phi)
   return true;
 }
 
-/* Returns a bit mask holding the positions of arguments in PHI
-   that have empty (or possibly empty) definitions.  */
+/* Return a bitset holding the positions of arguments in PHI with empty
+   (or possibly empty) definitions.  */
 
 static unsigned
 compute_uninit_opnds_pos (gphi *phi)
@@ -967,7 +955,7 @@  compute_uninit_opnds_pos (gphi *phi)
 
   unsigned n = gimple_phi_num_args (phi);
   /* Bail out for phi with too many args.  */
-  if (n > max_phi_args)
+  if (n > predicate::func_t::max_phi_args)
     return 0;
 
   for (unsigned i = 0; i < n; ++i)
@@ -990,2300 +978,231 @@  compute_uninit_opnds_pos (gphi *phi)
   return uninit_opnds;
 }
 
-/* Find the immediate postdominator of the specified basic block BLOCK.  */
-
-static inline basic_block
-find_pdom (basic_block block)
-{
-  if (block == EXIT_BLOCK_PTR_FOR_FN (cfun))
-    return EXIT_BLOCK_PTR_FOR_FN (cfun);
-  else
-    {
-      basic_block bb = get_immediate_dominator (CDI_POST_DOMINATORS, block);
-      if (!bb)
-	return EXIT_BLOCK_PTR_FOR_FN (cfun);
-      return bb;
-    }
-}
-
-/* Find the immediate dominator of the specified basic block BLOCK.  */
+/* Function object type used to determine whether an expression
+   is of interest to the predicate analyzer.  */
 
-static inline basic_block
-find_dom (basic_block block)
+struct uninit_undef_val_t: public predicate::func_t
 {
-  if (block == ENTRY_BLOCK_PTR_FOR_FN (cfun))
-    return ENTRY_BLOCK_PTR_FOR_FN (cfun);
-  else
-    {
-      basic_block bb = get_immediate_dominator (CDI_DOMINATORS, block);
-      if (!bb)
-	return ENTRY_BLOCK_PTR_FOR_FN (cfun);
-      return bb;
-    }
-}
+  virtual bool operator()(tree) override;
+  virtual unsigned phi_arg_set (gphi *) override;
+};
 
-/* Returns true if BB1 is postdominating BB2 and BB1 is
-   not a loop exit bb.  The loop exit bb check is simple and does
-   not cover all cases.  */
+/* Return true if the argument is an expression of interest.  */
 
-static bool
-is_non_loop_exit_postdominating (basic_block bb1, basic_block bb2)
+bool
+uninit_undef_val_t::operator()(tree val)
 {
-  if (!dominated_by_p (CDI_POST_DOMINATORS, bb2, bb1))
-    return false;
-
-  if (single_pred_p (bb1) && !single_succ_p (bb2))
-    return false;
+  if (TREE_CODE (val) == SSA_NAME)
+    return uninit_undefined_value_p (val);
 
-  return true;
+  return false;
 }
 
-/* Find the closest postdominator of a specified BB, which is control
-   equivalent to BB.  */
+/* Return a bitset of PHI arguments of interest.  */
 
-static inline basic_block
-find_control_equiv_block (basic_block bb)
+unsigned
+uninit_undef_val_t::phi_arg_set (gphi *phi)
 {
-  basic_block pdom = find_pdom (bb);
-
-  /* Skip the postdominating bb that is also loop exit.  */
-  if (!is_non_loop_exit_postdominating (pdom, bb))
-    return NULL;
-
-  if (dominated_by_p (CDI_DOMINATORS, pdom, bb))
-    return pdom;
-
-  return NULL;
+  return compute_uninit_opnds_pos (phi);
 }
 
-#define MAX_NUM_CHAINS 8
-#define MAX_CHAIN_LEN 5
-#define MAX_POSTDOM_CHECK 8
-#define MAX_SWITCH_CASES 40
-
-/* Computes the control dependence chains (paths of edges)
-   for DEP_BB up to the dominating basic block BB (the head node of a
-   chain should be dominated by it).  CD_CHAINS is pointer to an
-   array holding the result chains.  CUR_CD_CHAIN is the current
-   chain being computed.  *NUM_CHAINS is total number of chains.  The
-   function returns true if the information is successfully computed,
-   return false if there is no control dependence or not computed.  */
+/* Searches through all uses of a potentially
+   uninitialized variable defined by PHI and returns a use
+   statement if the use is not properly guarded.  It returns
+   NULL if all uses are guarded.  UNINIT_OPNDS is a bitvector
+   holding the position(s) of uninit PHI operands.  WORKLIST
+   is the vector of candidate phis that may be updated by this
+   function.  ADDED_TO_WORKLIST is the pointer set tracking
+   if the new phi is already in the worklist.  */
 
-static bool
-compute_control_dep_chain (basic_block bb, basic_block dep_bb,
-			   vec<edge> *cd_chains,
-			   size_t *num_chains,
-			   vec<edge> *cur_cd_chain,
-			   int *num_calls)
+static gimple *
+find_uninit_use (gphi *phi, unsigned uninit_opnds,
+		 vec<gphi *> *worklist, hash_set<gphi *> *added_to_worklist)
 {
-  edge_iterator ei;
-  edge e;
-  size_t i;
-  bool found_cd_chain = false;
-  size_t cur_chain_len = 0;
-
-  if (*num_calls > param_uninit_control_dep_attempts)
-    return false;
-  ++*num_calls;
-
-  /* Could use a set instead.  */
-  cur_chain_len = cur_cd_chain->length ();
-  if (cur_chain_len > MAX_CHAIN_LEN)
-    return false;
+  /* The Boolean predicate guarding the PHI definition.  Initialized
+     lazily from PHI in the first call to is_use_guarded() and cached
+     for subsequent iterations.  */
+  uninit_undef_val_t eval;
+  predicate def_preds (eval);
 
-  for (i = 0; i < cur_chain_len; i++)
-    {
-      edge e = (*cur_cd_chain)[i];
-      /* Cycle detected.  */
-      if (e->src == bb)
-	return false;
-    }
-
-  FOR_EACH_EDGE (e, ei, bb->succs)
+  use_operand_p use_p;
+  imm_use_iterator iter;
+  tree phi_result = gimple_phi_result (phi);
+  FOR_EACH_IMM_USE_FAST (use_p, iter, phi_result)
     {
-      basic_block cd_bb;
-      int post_dom_check = 0;
-      if (e->flags & (EDGE_FAKE | EDGE_ABNORMAL))
+      gimple *use_stmt = USE_STMT (use_p);
+      if (is_gimple_debug (use_stmt))
 	continue;
 
-      cd_bb = e->dest;
-      cur_cd_chain->safe_push (e);
-      while (!is_non_loop_exit_postdominating (cd_bb, bb))
-	{
-	  if (cd_bb == dep_bb)
-	    {
-	      /* Found a direct control dependence.  */
-	      if (*num_chains < MAX_NUM_CHAINS)
-		{
-		  cd_chains[*num_chains] = cur_cd_chain->copy ();
-		  (*num_chains)++;
-		}
-	      found_cd_chain = true;
-	      /* Check path from next edge.  */
-	      break;
-	    }
+      basic_block use_bb;
+      if (gphi *use_phi = dyn_cast<gphi *> (use_stmt))
+	use_bb = gimple_phi_arg_edge (use_phi,
+				      PHI_ARG_INDEX_FROM_USE (use_p))->src;
+      else
+	use_bb = gimple_bb (use_stmt);
 
-	  /* Now check if DEP_BB is indirectly control dependent on BB.  */
-	  if (compute_control_dep_chain (cd_bb, dep_bb, cd_chains, num_chains,
-					 cur_cd_chain, num_calls))
-	    {
-	      found_cd_chain = true;
-	      break;
-	    }
+      if (def_preds.is_use_guarded (use_stmt, use_bb, phi, uninit_opnds))
+	continue;
 
-	  cd_bb = find_pdom (cd_bb);
-	  post_dom_check++;
-	  if (cd_bb == EXIT_BLOCK_PTR_FOR_FN (cfun)
-	      || post_dom_check > MAX_POSTDOM_CHECK)
-	    break;
+      if (dump_file && (dump_flags & TDF_DETAILS))
+	{
+	  fprintf (dump_file, "Found unguarded use in bb %u: ",
+		   use_bb->index);
+	  print_gimple_stmt (dump_file, use_stmt, 0);
 	}
-      cur_cd_chain->pop ();
-      gcc_assert (cur_cd_chain->length () == cur_chain_len);
-    }
-  gcc_assert (cur_cd_chain->length () == cur_chain_len);
-
-  return found_cd_chain;
-}
-
-/* The type to represent a simple predicate.  */
-
-struct pred_info
-{
-  tree pred_lhs;
-  tree pred_rhs;
-  enum tree_code cond_code;
-  bool invert;
-};
-
-/* The type to represent a sequence of predicates grouped
-  with .AND. operation.  */
-
-typedef vec<pred_info, va_heap, vl_ptr> pred_chain;
-
-/* The type to represent a sequence of pred_chains grouped
-  with .OR. operation.  */
-
-typedef vec<pred_chain, va_heap, vl_ptr> pred_chain_union;
-
-/* Converts the chains of control dependence edges into a set of
-   predicates.  A control dependence chain is represented by a vector
-   edges.  DEP_CHAINS points to an array of dependence chains.
-   NUM_CHAINS is the size of the chain array.  One edge in a dependence
-   chain is mapped to predicate expression represented by pred_info
-   type.  One dependence chain is converted to a composite predicate that
-   is the result of AND operation of pred_info mapped to each edge.
-   A composite predicate is presented by a vector of pred_info.  On
-   return, *PREDS points to the resulting array of composite predicates.
-   *NUM_PREDS is the number of composite predictes.  */
-
-static bool
-convert_control_dep_chain_into_preds (vec<edge> *dep_chains,
-				      size_t num_chains,
-				      pred_chain_union *preds)
-{
-  bool has_valid_pred = false;
-  size_t i, j;
-  if (num_chains == 0 || num_chains >= MAX_NUM_CHAINS)
-    return false;
-
-  /* Now convert the control dep chain into a set
-     of predicates.  */
-  preds->reserve (num_chains);
-
-  for (i = 0; i < num_chains; i++)
-    {
-      vec<edge> one_cd_chain = dep_chains[i];
+      /* Found one real use, return.  */
+      if (gimple_code (use_stmt) != GIMPLE_PHI)
+	return use_stmt;
 
-      has_valid_pred = false;
-      pred_chain t_chain = vNULL;
-      for (j = 0; j < one_cd_chain.length (); j++)
+      /* Found a phi use that is not guarded,
+	 add the phi to the worklist.  */
+      if (!added_to_worklist->add (as_a<gphi *> (use_stmt)))
 	{
-	  gimple *cond_stmt;
-	  gimple_stmt_iterator gsi;
-	  basic_block guard_bb;
-	  pred_info one_pred;
-	  edge e;
-
-	  e = one_cd_chain[j];
-	  guard_bb = e->src;
-	  gsi = gsi_last_bb (guard_bb);
-	  /* Ignore empty forwarder blocks.  */
-	  if (empty_block_p (guard_bb) && single_succ_p (guard_bb))
-	    continue;
-	  /* An empty basic block here is likely a PHI, and is not one
-	     of the cases we handle below.  */
-	  if (gsi_end_p (gsi))
+	  if (dump_file && (dump_flags & TDF_DETAILS))
 	    {
-	      has_valid_pred = false;
-	      break;
+	      fprintf (dump_file, "[WORKLIST]: Update worklist with phi: ");
+	      print_gimple_stmt (dump_file, use_stmt, 0);
 	    }
-	  cond_stmt = gsi_stmt (gsi);
-	  if (is_gimple_call (cond_stmt) && EDGE_COUNT (e->src->succs) >= 2)
-	    /* Ignore EH edge.  Can add assertion on the other edge's flag.  */
-	    continue;
-	  /* Skip if there is essentially one succesor.  */
-	  if (EDGE_COUNT (e->src->succs) == 2)
-	    {
-	      edge e1;
-	      edge_iterator ei1;
-	      bool skip = false;
 
-	      FOR_EACH_EDGE (e1, ei1, e->src->succs)
-		{
-		  if (EDGE_COUNT (e1->dest->succs) == 0)
-		    {
-		      skip = true;
-		      break;
-		    }
-		}
-	      if (skip)
-		continue;
-	    }
-	  if (gimple_code (cond_stmt) == GIMPLE_COND)
-	    {
-	      one_pred.pred_lhs = gimple_cond_lhs (cond_stmt);
-	      one_pred.pred_rhs = gimple_cond_rhs (cond_stmt);
-	      one_pred.cond_code = gimple_cond_code (cond_stmt);
-	      one_pred.invert = !!(e->flags & EDGE_FALSE_VALUE);
-	      t_chain.safe_push (one_pred);
-	      has_valid_pred = true;
-	    }
-	  else if (gswitch *gs = dyn_cast<gswitch *> (cond_stmt))
-	    {
-	      /* Avoid quadratic behavior.  */
-	      if (gimple_switch_num_labels (gs) > MAX_SWITCH_CASES)
-		{
-		  has_valid_pred = false;
-		  break;
-		}
-	      /* Find the case label.  */
-	      tree l = NULL_TREE;
-	      unsigned idx;
-	      for (idx = 0; idx < gimple_switch_num_labels (gs); ++idx)
-		{
-		  tree tl = gimple_switch_label (gs, idx);
-		  if (e->dest == label_to_block (cfun, CASE_LABEL (tl)))
-		    {
-		      if (!l)
-			l = tl;
-		      else
-			{
-			  l = NULL_TREE;
-			  break;
-			}
-		    }
-		}
-	      /* If more than one label reaches this block or the case
-		 label doesn't have a single value (like the default one)
-		 fail.  */
-	      if (!l
-		  || !CASE_LOW (l)
-		  || (CASE_HIGH (l)
-		      && !operand_equal_p (CASE_LOW (l), CASE_HIGH (l), 0)))
-		{
-		  has_valid_pred = false;
-		  break;
-		}
-	      one_pred.pred_lhs = gimple_switch_index (gs);
-	      one_pred.pred_rhs = CASE_LOW (l);
-	      one_pred.cond_code = EQ_EXPR;
-	      one_pred.invert = false;
-	      t_chain.safe_push (one_pred);
-	      has_valid_pred = true;
-	    }
-	  else
-	    {
-	      has_valid_pred = false;
-	      break;
-	    }
+	  worklist->safe_push (as_a<gphi *> (use_stmt));
+	  possibly_undefined_names->add (phi_result);
 	}
-
-      if (!has_valid_pred)
-	break;
-      else
-	preds->safe_push (t_chain);
-    }
-  return has_valid_pred;
-}
-
-/* Computes all control dependence chains for USE_BB.  The control
-   dependence chains are then converted to an array of composite
-   predicates pointed to by PREDS.  PHI_BB is the basic block of
-   the phi whose result is used in USE_BB.  */
-
-static bool
-find_predicates (pred_chain_union *preds,
-		 basic_block phi_bb,
-		 basic_block use_bb)
-{
-  size_t num_chains = 0, i;
-  int num_calls = 0;
-  vec<edge> dep_chains[MAX_NUM_CHAINS];
-  auto_vec<edge, MAX_CHAIN_LEN + 1> cur_chain;
-  bool has_valid_pred = false;
-  basic_block cd_root = 0;
-
-  /* First find the closest bb that is control equivalent to PHI_BB
-     that also dominates USE_BB.  */
-  cd_root = phi_bb;
-  while (dominated_by_p (CDI_DOMINATORS, use_bb, cd_root))
-    {
-      basic_block ctrl_eq_bb = find_control_equiv_block (cd_root);
-      if (ctrl_eq_bb && dominated_by_p (CDI_DOMINATORS, use_bb, ctrl_eq_bb))
-	cd_root = ctrl_eq_bb;
-      else
-	break;
     }
 
-  compute_control_dep_chain (cd_root, use_bb, dep_chains, &num_chains,
-			     &cur_chain, &num_calls);
-
-  has_valid_pred
-    = convert_control_dep_chain_into_preds (dep_chains, num_chains, preds);
-  for (i = 0; i < num_chains; i++)
-    dep_chains[i].release ();
-  return has_valid_pred;
+  return NULL;
 }
 
-/* Computes the set of incoming edges of PHI that have non empty
-   definitions of a phi chain.  The collection will be done
-   recursively on operands that are defined by phis.  CD_ROOT
-   is the control dependence root.  *EDGES holds the result, and
-   VISITED_PHIS is a pointer set for detecting cycles.  */
+/* Look for inputs to PHI that are SSA_NAMEs that have empty definitions
+   and gives warning if there exists a runtime path from the entry to a
+   use of the PHI def that does not contain a definition.  In other words,
+   the warning is on the real use.  The more dead paths that can be pruned
+   by the compiler, the fewer false positives the warning is.  WORKLIST
+   is a vector of candidate phis to be examined.  ADDED_TO_WORKLIST is
+   a pointer set tracking if the new phi is added to the worklist or not.  */
 
 static void
-collect_phi_def_edges (gphi *phi, basic_block cd_root,
-		       auto_vec<edge> *edges,
-		       hash_set<gimple *> *visited_phis)
+warn_uninitialized_phi (gphi *phi, vec<gphi *> *worklist,
+			hash_set<gphi *> *added_to_worklist)
 {
-  size_t i, n;
-  edge opnd_edge;
-  tree opnd;
+  /* Don't look at virtual operands.  */
+  if (virtual_operand_p (gimple_phi_result (phi)))
+    return;
 
-  if (visited_phis->add (phi))
+  unsigned uninit_opnds = compute_uninit_opnds_pos (phi);
+  if (MASK_EMPTY (uninit_opnds))
     return;
 
-  n = gimple_phi_num_args (phi);
-  for (i = 0; i < n; i++)
+  if (dump_file && (dump_flags & TDF_DETAILS))
     {
-      opnd_edge = gimple_phi_arg_edge (phi, i);
-      opnd = gimple_phi_arg_def (phi, i);
-
-      if (TREE_CODE (opnd) != SSA_NAME)
-	{
-	  if (dump_file && (dump_flags & TDF_DETAILS))
-	    {
-	      fprintf (dump_file, "\n[CHECK] Found def edge %d in ", (int) i);
-	      print_gimple_stmt (dump_file, phi, 0);
-	    }
-	  edges->safe_push (opnd_edge);
-	}
-      else
-	{
-	  gimple *def = SSA_NAME_DEF_STMT (opnd);
-
-	  if (gimple_code (def) == GIMPLE_PHI
-	      && dominated_by_p (CDI_DOMINATORS, gimple_bb (def), cd_root))
-	    collect_phi_def_edges (as_a<gphi *> (def), cd_root, edges,
-				   visited_phis);
-	  else if (!uninit_undefined_value_p (opnd))
-	    {
-	      if (dump_file && (dump_flags & TDF_DETAILS))
-		{
-		  fprintf (dump_file, "\n[CHECK] Found def edge %d in ",
-			   (int) i);
-		  print_gimple_stmt (dump_file, phi, 0);
-		}
-	      edges->safe_push (opnd_edge);
-	    }
-	}
+      fprintf (dump_file, "Examining phi: ");
+      print_gimple_stmt (dump_file, phi, 0);
     }
-}
 
-/* For each use edge of PHI, computes all control dependence chains.
-   The control dependence chains are then converted to an array of
-   composite predicates pointed to by PREDS.  */
-
-static bool
-find_def_preds (pred_chain_union *preds, gphi *phi)
-{
-  size_t num_chains = 0, i, n;
-  vec<edge> dep_chains[MAX_NUM_CHAINS];
-  auto_vec<edge, MAX_CHAIN_LEN + 1> cur_chain;
-  auto_vec<edge> def_edges;
-  bool has_valid_pred = false;
-  basic_block phi_bb, cd_root = 0;
-
-  phi_bb = gimple_bb (phi);
-  /* First find the closest dominating bb to be
-     the control dependence root.  */
-  cd_root = find_dom (phi_bb);
-  if (!cd_root)
-    return false;
+  gimple *uninit_use_stmt = find_uninit_use (phi, uninit_opnds,
+					     worklist, added_to_worklist);
 
-  hash_set<gimple *> visited_phis;
-  collect_phi_def_edges (phi, cd_root, &def_edges, &visited_phis);
+  /* All uses are properly guarded but a new PHI may have been added
+     to WORKLIST.  */
+  if (!uninit_use_stmt)
+    return;
 
-  n = def_edges.length ();
-  if (n == 0)
-    return false;
+  unsigned phiarg_index = MASK_FIRST_SET_BIT (uninit_opnds);
+  tree uninit_op = gimple_phi_arg_def (phi, phiarg_index);
+  if (SSA_NAME_VAR (uninit_op) == NULL_TREE)
+    return;
 
-  for (i = 0; i < n; i++)
+  location_t loc = UNKNOWN_LOCATION;
+  if (gimple_phi_arg_has_location (phi, phiarg_index))
+    loc = gimple_phi_arg_location (phi, phiarg_index);
+  else
     {
-      size_t prev_nc, j;
-      int num_calls = 0;
-      edge opnd_edge;
-
-      opnd_edge = def_edges[i];
-      prev_nc = num_chains;
-      compute_control_dep_chain (cd_root, opnd_edge->src, dep_chains,
-				 &num_chains, &cur_chain, &num_calls);
-
-      /* Now update the newly added chains with
-	 the phi operand edge:  */
-      if (EDGE_COUNT (opnd_edge->src->succs) > 1)
+      tree arg_def = gimple_phi_arg_def (phi, phiarg_index);
+      if (TREE_CODE (arg_def) == SSA_NAME)
 	{
-	  if (prev_nc == num_chains && num_chains < MAX_NUM_CHAINS)
-	    dep_chains[num_chains++] = vNULL;
-	  for (j = prev_nc; j < num_chains; j++)
-	    dep_chains[j].safe_push (opnd_edge);
+	  gimple *def_stmt = SSA_NAME_DEF_STMT (arg_def);
+	  if (gphi *arg_phi = dyn_cast<gphi *> (def_stmt))
+	    {
+	      unsigned uop = compute_uninit_opnds_pos (arg_phi);
+	      unsigned idx = MASK_FIRST_SET_BIT (uop);
+	      if (idx < gimple_phi_num_args (arg_phi)
+		  && gimple_phi_arg_has_location (arg_phi, idx))
+		loc = gimple_phi_arg_location (arg_phi, idx);
+	    }
 	}
     }
 
-  has_valid_pred
-    = convert_control_dep_chain_into_preds (dep_chains, num_chains, preds);
-  for (i = 0; i < num_chains; i++)
-    dep_chains[i].release ();
-  return has_valid_pred;
+  warn_uninit (OPT_Wmaybe_uninitialized, uninit_op,
+	       SSA_NAME_VAR (uninit_op),
+	       "%qD may be used uninitialized in this function",
+	       uninit_use_stmt, loc);
 }
 
-/* Dump a pred_info.  */
-
-static void
-dump_pred_info (pred_info one_pred)
+static bool
+gate_warn_uninitialized (void)
 {
-  if (one_pred.invert)
-    fprintf (dump_file, " (.NOT.) ");
-  print_generic_expr (dump_file, one_pred.pred_lhs);
-  fprintf (dump_file, " %s ", op_symbol_code (one_pred.cond_code));
-  print_generic_expr (dump_file, one_pred.pred_rhs);
+  return warn_uninitialized || warn_maybe_uninitialized;
 }
 
-/* Dump a pred_chain.  */
+namespace {
 
-static void
-dump_pred_chain (pred_chain one_pred_chain)
+const pass_data pass_data_late_warn_uninitialized =
 {
-  size_t np = one_pred_chain.length ();
-  for (size_t j = 0; j < np; j++)
-    {
-      dump_pred_info (one_pred_chain[j]);
-      if (j < np - 1)
-	fprintf (dump_file, " (.AND.) ");
-      else
-	fprintf (dump_file, "\n");
-    }
-}
-
-/* Dumps the predicates (PREDS) for USESTMT.  */
+  GIMPLE_PASS, /* type */
+  "uninit", /* name */
+  OPTGROUP_NONE, /* optinfo_flags */
+  TV_NONE, /* tv_id */
+  PROP_ssa, /* properties_required */
+  0, /* properties_provided */
+  0, /* properties_destroyed */
+  0, /* todo_flags_start */
+  0, /* todo_flags_finish */
+};
 
-static void
-dump_predicates (gimple *usestmt, pred_chain_union preds, const char *msg)
+class pass_late_warn_uninitialized : public gimple_opt_pass
 {
-  fprintf (dump_file, "%s", msg);
-  if (usestmt)
-    {
-      print_gimple_stmt (dump_file, usestmt, 0);
-      fprintf (dump_file, "is guarded by :\n\n");
-    }
-  size_t num_preds = preds.length ();
-  for (size_t i = 0; i < num_preds; i++)
-    {
-      dump_pred_chain (preds[i]);
-      if (i < num_preds - 1)
-	fprintf (dump_file, "(.OR.)\n");
-      else
-	fprintf (dump_file, "\n\n");
-    }
-}
+public:
+  pass_late_warn_uninitialized (gcc::context *ctxt)
+    : gimple_opt_pass (pass_data_late_warn_uninitialized, ctxt)
+  {}
+
+  /* opt_pass methods: */
+  opt_pass *clone () { return new pass_late_warn_uninitialized (m_ctxt); }
+  virtual bool gate (function *) { return gate_warn_uninitialized (); }
+  virtual unsigned int execute (function *);
 
-/* Destroys the predicate set *PREDS.  */
+}; // class pass_late_warn_uninitialized
 
 static void
-destroy_predicate_vecs (pred_chain_union *preds)
+execute_late_warn_uninitialized (function *fun)
 {
-  size_t i;
-
-  size_t n = preds->length ();
-  for (i = 0; i < n; i++)
-    (*preds)[i].release ();
-  preds->release ();
-}
-
-/* Computes the 'normalized' conditional code with operand
-   swapping and condition inversion.  */
+  basic_block bb;
+  gphi_iterator gsi;
+  vec<gphi *> worklist = vNULL;
 
-static enum tree_code
-get_cmp_code (enum tree_code orig_cmp_code, bool swap_cond, bool invert)
-{
-  enum tree_code tc = orig_cmp_code;
+  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (CDI_POST_DOMINATORS);
+  /* Re-do the plain uninitialized variable check, as optimization may have
+     straightened control flow.  Do this first so that we don't accidentally
+     get a "may be" warning when we'd have seen an "is" warning later.  */
+  warn_uninitialized_vars (/*warn_maybe_uninitialized=*/1);
 
-  if (swap_cond)
-    tc = swap_tree_comparison (orig_cmp_code);
-  if (invert)
-    tc = invert_tree_comparison (tc, false);
+  timevar_push (TV_TREE_UNINIT);
 
-  switch (tc)
-    {
-    case LT_EXPR:
-    case LE_EXPR:
-    case GT_EXPR:
-    case GE_EXPR:
-    case EQ_EXPR:
-    case NE_EXPR:
-      break;
-    default:
-      return ERROR_MARK;
-    }
-  return tc;
-}
+  possibly_undefined_names = new hash_set<tree>;
+  hash_set<gphi *> added_to_worklist;
 
-/* Returns whether VAL CMPC BOUNDARY is true.  */
-
-static bool
-is_value_included_in (tree val, tree boundary, enum tree_code cmpc)
-{
-  bool inverted = false;
-  bool result;
-
-  /* Only handle integer constant here.  */
-  if (TREE_CODE (val) != INTEGER_CST || TREE_CODE (boundary) != INTEGER_CST)
-    return true;
-
-  if (cmpc == GE_EXPR || cmpc == GT_EXPR || cmpc == NE_EXPR)
-    {
-      cmpc = invert_tree_comparison (cmpc, false);
-      inverted = true;
-    }
-
-  if (cmpc == EQ_EXPR)
-    result = tree_int_cst_equal (val, boundary);
-  else if (cmpc == LT_EXPR)
-    result = tree_int_cst_lt (val, boundary);
-  else
-    {
-      gcc_assert (cmpc == LE_EXPR);
-      result = tree_int_cst_le (val, boundary);
-    }
-
-  if (inverted)
-    result ^= 1;
-
-  return result;
-}
-
-/* Returns whether VAL satisfies (x CMPC BOUNDARY) predicate.  CMPC can be
-   either one of the range comparison codes ({GE,LT,EQ,NE}_EXPR and the like),
-   or BIT_AND_EXPR.  EXACT_P is only meaningful for the latter.  It modifies the
-   question from whether VAL & BOUNDARY != 0 to whether VAL & BOUNDARY == VAL.
-   For other values of CMPC, EXACT_P is ignored.  */
-
-static bool
-value_sat_pred_p (tree val, tree boundary, enum tree_code cmpc,
-		  bool exact_p = false)
-{
-  if (cmpc != BIT_AND_EXPR)
-    return is_value_included_in (val, boundary, cmpc);
-
-  wide_int andw = wi::to_wide (val) & wi::to_wide (boundary);
-  if (exact_p)
-    return andw == wi::to_wide (val);
-  else
-    return andw.to_uhwi ();
-}
-
-/* Returns true if PRED is common among all the predicate
-   chains (PREDS) (and therefore can be factored out).  */
-
-static bool
-find_matching_predicate_in_rest_chains (pred_info pred, pred_chain_union preds)
-{
-  size_t i, j, n;
-
-  /* Trival case.  */
-  if (preds.length () == 1)
-    return true;
-
-  for (i = 1; i < preds.length (); i++)
-    {
-      bool found = false;
-      pred_chain one_chain = preds[i];
-      n = one_chain.length ();
-      for (j = 0; j < n; j++)
-	{
-	  pred_info pred2 = one_chain[j];
-	  /* Can relax the condition comparison to not
-	     use address comparison.  However, the most common
-	     case is that multiple control dependent paths share
-	     a common path prefix, so address comparison should
-	     be ok.  */
-
-	  if (operand_equal_p (pred2.pred_lhs, pred.pred_lhs, 0)
-	      && operand_equal_p (pred2.pred_rhs, pred.pred_rhs, 0)
-	      && pred2.invert == pred.invert)
-	    {
-	      found = true;
-	      break;
-	    }
-	}
-      if (!found)
-	return false;
-    }
-  return true;
-}
-
-/* Forward declaration.  */
-static bool is_use_properly_guarded (gimple *use_stmt,
-				     basic_block use_bb,
-				     gphi *phi,
-				     unsigned uninit_opnds,
-				     pred_chain_union *def_preds,
-				     hash_set<gphi *> *visited_phis);
-
-/* Returns true if all uninitialized opnds are pruned.  Returns false
-   otherwise.  PHI is the phi node with uninitialized operands,
-   UNINIT_OPNDS is the bitmap of the uninitialize operand positions,
-   FLAG_DEF is the statement defining the flag guarding the use of the
-   PHI output, BOUNDARY_CST is the const value used in the predicate
-   associated with the flag, CMP_CODE is the comparison code used in
-   the predicate, VISITED_PHIS is the pointer set of phis visited, and
-   VISITED_FLAG_PHIS is the pointer to the pointer set of flag definitions
-   that are also phis.
-
-   Example scenario:
-
-   BB1:
-   flag_1 = phi <0, 1>			// (1)
-   var_1  = phi <undef, some_val>
-
-
-   BB2:
-   flag_2 = phi <0,   flag_1, flag_1>   // (2)
-   var_2  = phi <undef, var_1, var_1>
-   if (flag_2 == 1)
-      goto BB3;
-
-   BB3:
-   use of var_2				// (3)
-
-   Because some flag arg in (1) is not constant, if we do not look into the
-   flag phis recursively, it is conservatively treated as unknown and var_1
-   is thought to be flowed into use at (3).  Since var_1 is potentially
-   uninitialized a false warning will be emitted.
-   Checking recursively into (1), the compiler can find out that only some_val
-   (which is defined) can flow into (3) which is OK.  */
-
-static bool
-prune_uninit_phi_opnds (gphi *phi, unsigned uninit_opnds, gphi *flag_def,
-			tree boundary_cst, enum tree_code cmp_code,
-			hash_set<gphi *> *visited_phis,
-			bitmap *visited_flag_phis)
-{
-  unsigned i;
-
-  for (i = 0; i < MIN (max_phi_args, gimple_phi_num_args (flag_def)); i++)
-    {
-      tree flag_arg;
-
-      if (!MASK_TEST_BIT (uninit_opnds, i))
-	continue;
-
-      flag_arg = gimple_phi_arg_def (flag_def, i);
-      if (!is_gimple_constant (flag_arg))
-	{
-	  gphi *flag_arg_def, *phi_arg_def;
-	  tree phi_arg;
-	  unsigned uninit_opnds_arg_phi;
-
-	  if (TREE_CODE (flag_arg) != SSA_NAME)
-	    return false;
-	  flag_arg_def = dyn_cast<gphi *> (SSA_NAME_DEF_STMT (flag_arg));
-	  if (!flag_arg_def)
-	    return false;
-
-	  phi_arg = gimple_phi_arg_def (phi, i);
-	  if (TREE_CODE (phi_arg) != SSA_NAME)
-	    return false;
-
-	  phi_arg_def = dyn_cast<gphi *> (SSA_NAME_DEF_STMT (phi_arg));
-	  if (!phi_arg_def)
-	    return false;
-
-	  if (gimple_bb (phi_arg_def) != gimple_bb (flag_arg_def))
-	    return false;
-
-	  if (!*visited_flag_phis)
-	    *visited_flag_phis = BITMAP_ALLOC (NULL);
-
-	  tree phi_result = gimple_phi_result (flag_arg_def);
-	  if (bitmap_bit_p (*visited_flag_phis, SSA_NAME_VERSION (phi_result)))
-	    return false;
-
-	  bitmap_set_bit (*visited_flag_phis,
-			  SSA_NAME_VERSION (gimple_phi_result (flag_arg_def)));
-
-	  /* Now recursively prune the uninitialized phi args.  */
-	  uninit_opnds_arg_phi = compute_uninit_opnds_pos (phi_arg_def);
-	  if (!prune_uninit_phi_opnds
-	      (phi_arg_def, uninit_opnds_arg_phi, flag_arg_def, boundary_cst,
-	       cmp_code, visited_phis, visited_flag_phis))
-	    return false;
-
-	  phi_result = gimple_phi_result (flag_arg_def);
-	  bitmap_clear_bit (*visited_flag_phis, SSA_NAME_VERSION (phi_result));
-	  continue;
-	}
-
-      /* Now check if the constant is in the guarded range.  */
-      if (is_value_included_in (flag_arg, boundary_cst, cmp_code))
-	{
-	  tree opnd;
-	  gimple *opnd_def;
-
-	  /* Now that we know that this undefined edge is not
-	     pruned.  If the operand is defined by another phi,
-	     we can further prune the incoming edges of that
-	     phi by checking the predicates of this operands.  */
-
-	  opnd = gimple_phi_arg_def (phi, i);
-	  opnd_def = SSA_NAME_DEF_STMT (opnd);
-	  if (gphi *opnd_def_phi = dyn_cast <gphi *> (opnd_def))
-	    {
-	      edge opnd_edge;
-	      unsigned uninit_opnds2 = compute_uninit_opnds_pos (opnd_def_phi);
-	      if (!MASK_EMPTY (uninit_opnds2))
-		{
-		  pred_chain_union def_preds = vNULL;
-		  bool ok;
-		  opnd_edge = gimple_phi_arg_edge (phi, i);
-		  ok = is_use_properly_guarded (phi,
-						opnd_edge->src,
-						opnd_def_phi,
-						uninit_opnds2,
-						&def_preds,
-						visited_phis);
-		  destroy_predicate_vecs (&def_preds);
-		  if (!ok)
-		    return false;
-		}
-	    }
-	  else
-	    return false;
-	}
-    }
-
-  return true;
-}
-
-/* A helper function finds predicate which will be examined against uninit
-   paths.  If there is no "flag_var cmp const" form predicate, the function
-   tries to find predicate of form like "flag_var cmp flag_var" with value
-   range info.  PHI is the phi node whose incoming (undefined) paths need to
-   be examined.  On success, the function returns the comparsion code, sets
-   defintion gimple of the flag_var to FLAG_DEF, sets boundary_cst to
-   BOUNDARY_CST.  On fail, the function returns ERROR_MARK.  */
-
-static enum tree_code
-find_var_cmp_const (pred_chain_union preds, gphi *phi, gimple **flag_def,
-		    tree *boundary_cst)
-{
-  enum tree_code vrinfo_code = ERROR_MARK, code;
-  gimple *vrinfo_def = NULL;
-  tree vrinfo_cst = NULL, cond_lhs, cond_rhs;
-
-  gcc_assert (preds.length () > 0);
-  pred_chain the_pred_chain = preds[0];
-  for (unsigned i = 0; i < the_pred_chain.length (); i++)
-    {
-      bool use_vrinfo_p = false;
-      pred_info the_pred = the_pred_chain[i];
-      cond_lhs = the_pred.pred_lhs;
-      cond_rhs = the_pred.pred_rhs;
-      if (cond_lhs == NULL_TREE || cond_rhs == NULL_TREE)
-	continue;
-
-      code = get_cmp_code (the_pred.cond_code, false, the_pred.invert);
-      if (code == ERROR_MARK)
-	continue;
-
-      if (TREE_CODE (cond_lhs) == SSA_NAME && is_gimple_constant (cond_rhs))
-	;
-      else if (TREE_CODE (cond_rhs) == SSA_NAME
-	       && is_gimple_constant (cond_lhs))
-	{
-	  std::swap (cond_lhs, cond_rhs);
-	  if ((code = get_cmp_code (code, true, false)) == ERROR_MARK)
-	    continue;
-	}
-      /* Check if we can take advantage of "flag_var comp flag_var" predicate
-	 with value range info.  Note only first of such case is handled.  */
-      else if (vrinfo_code == ERROR_MARK
-	       && TREE_CODE (cond_lhs) == SSA_NAME
-	       && TREE_CODE (cond_rhs) == SSA_NAME)
-	{
-	  gimple* lhs_def = SSA_NAME_DEF_STMT (cond_lhs);
-	  if (!lhs_def || gimple_code (lhs_def) != GIMPLE_PHI
-	      || gimple_bb (lhs_def) != gimple_bb (phi))
-	    {
-	      std::swap (cond_lhs, cond_rhs);
-	      if ((code = get_cmp_code (code, true, false)) == ERROR_MARK)
-		continue;
-	    }
-
-	  /* Check value range info of rhs, do following transforms:
-	       flag_var < [min, max]  ->  flag_var < max
-	       flag_var > [min, max]  ->  flag_var > min
-
-	     We can also transform LE_EXPR/GE_EXPR to LT_EXPR/GT_EXPR:
-	       flag_var <= [min, max] ->  flag_var < [min, max+1]
-	       flag_var >= [min, max] ->  flag_var > [min-1, max]
-	     if no overflow/wrap.  */
-	  tree type = TREE_TYPE (cond_lhs);
-	  value_range r;
-	  if (!INTEGRAL_TYPE_P (type)
-	      || !get_range_query (cfun)->range_of_expr (r, cond_rhs)
-	      || r.kind () != VR_RANGE)
-	    continue;
-	  wide_int min = r.lower_bound ();
-	  wide_int max = r.upper_bound ();
-	  if (code == LE_EXPR
-	      && max != wi::max_value (TYPE_PRECISION (type), TYPE_SIGN (type)))
-	    {
-	      code = LT_EXPR;
-	      max = max + 1;
-	    }
-	  if (code == GE_EXPR
-	      && min != wi::min_value (TYPE_PRECISION (type), TYPE_SIGN (type)))
-	    {
-	      code = GT_EXPR;
-	      min = min - 1;
-	    }
-	  if (code == LT_EXPR)
-	    cond_rhs = wide_int_to_tree (type, max);
-	  else if (code == GT_EXPR)
-	    cond_rhs = wide_int_to_tree (type, min);
-	  else
-	    continue;
-
-	  use_vrinfo_p = true;
-	}
-      else
-	continue;
-
-      if ((*flag_def = SSA_NAME_DEF_STMT (cond_lhs)) == NULL)
-	continue;
-
-      if (gimple_code (*flag_def) != GIMPLE_PHI
-	  || gimple_bb (*flag_def) != gimple_bb (phi)
-	  || !find_matching_predicate_in_rest_chains (the_pred, preds))
-	continue;
-
-      /* Return if any "flag_var comp const" predicate is found.  */
-      if (!use_vrinfo_p)
-	{
-	  *boundary_cst = cond_rhs;
-	  return code;
-	}
-      /* Record if any "flag_var comp flag_var[vinfo]" predicate is found.  */
-      else if (vrinfo_code == ERROR_MARK)
-	{
-	  vrinfo_code = code;
-	  vrinfo_def = *flag_def;
-	  vrinfo_cst = cond_rhs;
-	}
-    }
-  /* Return the "flag_var cmp flag_var[vinfo]" predicate we found.  */
-  if (vrinfo_code != ERROR_MARK)
-    {
-      *flag_def = vrinfo_def;
-      *boundary_cst = vrinfo_cst;
-    }
-  return vrinfo_code;
-}
-
-/* A helper function that determines if the predicate set
-   of the use is not overlapping with that of the uninit paths.
-   The most common senario of guarded use is in Example 1:
-     Example 1:
-	   if (some_cond)
-	   {
-	      x = ...;
-	      flag = true;
-	   }
-
-	    ... some code ...
-
-	   if (flag)
-	      use (x);
-
-     The real world examples are usually more complicated, but similar
-     and usually result from inlining:
-
-	 bool init_func (int * x)
-	 {
-	     if (some_cond)
-		return false;
-	     *x  =  ..
-	     return true;
-	 }
-
-	 void foo (..)
-	 {
-	     int x;
-
-	     if (!init_func (&x))
-		return;
-
-	     .. some_code ...
-	     use (x);
-	 }
-
-     Another possible use scenario is in the following trivial example:
-
-     Example 2:
-	  if (n > 0)
-	     x = 1;
-	  ...
-	  if (n > 0)
-	    {
-	      if (m < 2)
-		 .. = x;
-	    }
-
-     Predicate analysis needs to compute the composite predicate:
-
-       1) 'x' use predicate: (n > 0) .AND. (m < 2)
-       2) 'x' default value  (non-def) predicate: .NOT. (n > 0)
-       (the predicate chain for phi operand defs can be computed
-       starting from a bb that is control equivalent to the phi's
-       bb and is dominating the operand def.)
-
-       and check overlapping:
-	  (n > 0) .AND. (m < 2) .AND. (.NOT. (n > 0))
-	<==> false
-
-     This implementation provides framework that can handle
-     scenarios.  (Note that many simple cases are handled properly
-     without the predicate analysis -- this is due to jump threading
-     transformation which eliminates the merge point thus makes
-     path sensitive analysis unnecessary.)
-
-     PHI is the phi node whose incoming (undefined) paths need to be
-     pruned, and UNINIT_OPNDS is the bitmap holding uninit operand
-     positions.  VISITED_PHIS is the pointer set of phi stmts being
-     checked.  */
-
-static bool
-use_pred_not_overlap_with_undef_path_pred (pred_chain_union preds,
-					   gphi *phi, unsigned uninit_opnds,
-					   hash_set<gphi *> *visited_phis)
-{
-  gimple *flag_def = 0;
-  tree boundary_cst = 0;
-  enum tree_code cmp_code;
-  bitmap visited_flag_phis = NULL;
-  bool all_pruned = false;
-
-  /* Find within the common prefix of multiple predicate chains
-     a predicate that is a comparison of a flag variable against
-     a constant.  */
-  cmp_code = find_var_cmp_const (preds, phi, &flag_def, &boundary_cst);
-  if (cmp_code == ERROR_MARK)
-    return false;
-
-  /* Now check all the uninit incoming edge has a constant flag value
-     that is in conflict with the use guard/predicate.  */
-  all_pruned = prune_uninit_phi_opnds
-    (phi, uninit_opnds, as_a<gphi *> (flag_def), boundary_cst, cmp_code,
-     visited_phis, &visited_flag_phis);
-
-  if (visited_flag_phis)
-    BITMAP_FREE (visited_flag_phis);
-
-  return all_pruned;
-}
-
-/* The helper function returns true if two predicates X1 and X2
-   are equivalent.  It assumes the expressions have already
-   properly re-associated.  */
-
-static inline bool
-pred_equal_p (pred_info x1, pred_info x2)
-{
-  enum tree_code c1, c2;
-  if (!operand_equal_p (x1.pred_lhs, x2.pred_lhs, 0)
-      || !operand_equal_p (x1.pred_rhs, x2.pred_rhs, 0))
-    return false;
-
-  c1 = x1.cond_code;
-  if (x1.invert != x2.invert
-      && TREE_CODE_CLASS (x2.cond_code) == tcc_comparison)
-    c2 = invert_tree_comparison (x2.cond_code, false);
-  else
-    c2 = x2.cond_code;
-
-  return c1 == c2;
-}
-
-/* Returns true if the predication is testing !=.  */
-
-static inline bool
-is_neq_relop_p (pred_info pred)
-{
-
-  return ((pred.cond_code == NE_EXPR && !pred.invert)
-	  || (pred.cond_code == EQ_EXPR && pred.invert));
-}
-
-/* Returns true if pred is of the form X != 0.  */
-
-static inline bool
-is_neq_zero_form_p (pred_info pred)
-{
-  if (!is_neq_relop_p (pred) || !integer_zerop (pred.pred_rhs)
-      || TREE_CODE (pred.pred_lhs) != SSA_NAME)
-    return false;
-  return true;
-}
-
-/* The helper function returns true if two predicates X1
-   is equivalent to X2 != 0.  */
-
-static inline bool
-pred_expr_equal_p (pred_info x1, tree x2)
-{
-  if (!is_neq_zero_form_p (x1))
-    return false;
-
-  return operand_equal_p (x1.pred_lhs, x2, 0);
-}
-
-/* Returns true of the domain of single predicate expression
-   EXPR1 is a subset of that of EXPR2.  Returns false if it
-   cannot be proved.  */
-
-static bool
-is_pred_expr_subset_of (pred_info expr1, pred_info expr2)
-{
-  enum tree_code code1, code2;
-
-  if (pred_equal_p (expr1, expr2))
-    return true;
-
-  if ((TREE_CODE (expr1.pred_rhs) != INTEGER_CST)
-      || (TREE_CODE (expr2.pred_rhs) != INTEGER_CST))
-    return false;
-
-  if (!operand_equal_p (expr1.pred_lhs, expr2.pred_lhs, 0))
-    return false;
-
-  code1 = expr1.cond_code;
-  if (expr1.invert)
-    code1 = invert_tree_comparison (code1, false);
-  code2 = expr2.cond_code;
-  if (expr2.invert)
-    code2 = invert_tree_comparison (code2, false);
-
-  if (code2 == NE_EXPR && code1 == NE_EXPR)
-    return false;
-
-  if (code2 == NE_EXPR)
-    return !value_sat_pred_p (expr2.pred_rhs, expr1.pred_rhs, code1);
-
-  if (code1 == EQ_EXPR)
-    return value_sat_pred_p (expr1.pred_rhs, expr2.pred_rhs, code2);
-
-  if (code1 == code2)
-    return value_sat_pred_p (expr1.pred_rhs, expr2.pred_rhs, code2,
-			     code1 == BIT_AND_EXPR);
-
-  return false;
-}
-
-/* Returns true if the domain of PRED1 is a subset
-   of that of PRED2.  Returns false if it cannot be proved so.  */
-
-static bool
-is_pred_chain_subset_of (pred_chain pred1, pred_chain pred2)
-{
-  size_t np1, np2, i1, i2;
-
-  np1 = pred1.length ();
-  np2 = pred2.length ();
-
-  for (i2 = 0; i2 < np2; i2++)
-    {
-      bool found = false;
-      pred_info info2 = pred2[i2];
-      for (i1 = 0; i1 < np1; i1++)
-	{
-	  pred_info info1 = pred1[i1];
-	  if (is_pred_expr_subset_of (info1, info2))
-	    {
-	      found = true;
-	      break;
-	    }
-	}
-      if (!found)
-	return false;
-    }
-  return true;
-}
-
-/* Returns true if the domain defined by
-   one pred chain ONE_PRED is a subset of the domain
-   of *PREDS.  It returns false if ONE_PRED's domain is
-   not a subset of any of the sub-domains of PREDS
-   (corresponding to each individual chains in it), even
-   though it may be still be a subset of whole domain
-   of PREDS which is the union (ORed) of all its subdomains.
-   In other words, the result is conservative.  */
-
-static bool
-is_included_in (pred_chain one_pred, pred_chain_union preds)
-{
-  size_t i;
-  size_t n = preds.length ();
-
-  for (i = 0; i < n; i++)
-    {
-      if (is_pred_chain_subset_of (one_pred, preds[i]))
-	return true;
-    }
-
-  return false;
-}
-
-/* Compares two predicate sets PREDS1 and PREDS2 and returns
-   true if the domain defined by PREDS1 is a superset
-   of PREDS2's domain.  N1 and N2 are array sizes of PREDS1 and
-   PREDS2 respectively.  The implementation chooses not to build
-   generic trees (and relying on the folding capability of the
-   compiler), but instead performs brute force comparison of
-   individual predicate chains (won't be a compile time problem
-   as the chains are pretty short).  When the function returns
-   false, it does not necessarily mean *PREDS1 is not a superset
-   of *PREDS2, but mean it may not be so since the analysis cannot
-   prove it.  In such cases, false warnings may still be
-   emitted.  */
-
-static bool
-is_superset_of (pred_chain_union preds1, pred_chain_union preds2)
-{
-  size_t i, n2;
-  pred_chain one_pred_chain = vNULL;
-
-  n2 = preds2.length ();
-
-  for (i = 0; i < n2; i++)
-    {
-      one_pred_chain = preds2[i];
-      if (!is_included_in (one_pred_chain, preds1))
-	return false;
-    }
-
-  return true;
-}
-
-/* Returns true if X1 is the negate of X2.  */
-
-static inline bool
-pred_neg_p (pred_info x1, pred_info x2)
-{
-  enum tree_code c1, c2;
-  if (!operand_equal_p (x1.pred_lhs, x2.pred_lhs, 0)
-      || !operand_equal_p (x1.pred_rhs, x2.pred_rhs, 0))
-    return false;
-
-  c1 = x1.cond_code;
-  if (x1.invert == x2.invert)
-    c2 = invert_tree_comparison (x2.cond_code, false);
-  else
-    c2 = x2.cond_code;
-
-  return c1 == c2;
-}
-
-/* 1) ((x IOR y) != 0) AND (x != 0) is equivalent to (x != 0);
-   2) (X AND Y) OR (!X AND Y) is equivalent to Y;
-   3) X OR (!X AND Y) is equivalent to (X OR Y);
-   4) ((x IAND y) != 0) || (x != 0 AND y != 0)) is equivalent to
-      (x != 0 AND y != 0)
-   5) (X AND Y) OR (!X AND Z) OR (!Y AND Z) is equivalent to
-      (X AND Y) OR Z
-
-   PREDS is the predicate chains, and N is the number of chains.  */
-
-/* Helper function to implement rule 1 above.  ONE_CHAIN is
-   the AND predication to be simplified.  */
-
-static void
-simplify_pred (pred_chain *one_chain)
-{
-  size_t i, j, n;
-  bool simplified = false;
-  pred_chain s_chain = vNULL;
-
-  n = one_chain->length ();
-
-  for (i = 0; i < n; i++)
-    {
-      pred_info *a_pred = &(*one_chain)[i];
-
-      if (!a_pred->pred_lhs)
-	continue;
-      if (!is_neq_zero_form_p (*a_pred))
-	continue;
-
-      gimple *def_stmt = SSA_NAME_DEF_STMT (a_pred->pred_lhs);
-      if (gimple_code (def_stmt) != GIMPLE_ASSIGN)
-	continue;
-      if (gimple_assign_rhs_code (def_stmt) == BIT_IOR_EXPR)
-	{
-	  for (j = 0; j < n; j++)
-	    {
-	      pred_info *b_pred = &(*one_chain)[j];
-
-	      if (!b_pred->pred_lhs)
-		continue;
-	      if (!is_neq_zero_form_p (*b_pred))
-		continue;
-
-	      if (pred_expr_equal_p (*b_pred, gimple_assign_rhs1 (def_stmt))
-		  || pred_expr_equal_p (*b_pred, gimple_assign_rhs2 (def_stmt)))
-		{
-		  /* Mark a_pred for removal.  */
-		  a_pred->pred_lhs = NULL;
-		  a_pred->pred_rhs = NULL;
-		  simplified = true;
-		  break;
-		}
-	    }
-	}
-    }
-
-  if (!simplified)
-    return;
-
-  for (i = 0; i < n; i++)
-    {
-      pred_info *a_pred = &(*one_chain)[i];
-      if (!a_pred->pred_lhs)
-	continue;
-      s_chain.safe_push (*a_pred);
-    }
-
-  one_chain->release ();
-  *one_chain = s_chain;
-}
-
-/* The helper function implements the rule 2 for the
-   OR predicate PREDS.
-
-   2) (X AND Y) OR (!X AND Y) is equivalent to Y.  */
-
-static bool
-simplify_preds_2 (pred_chain_union *preds)
-{
-  size_t i, j, n;
-  bool simplified = false;
-  pred_chain_union s_preds = vNULL;
-
-  /* (X AND Y) OR (!X AND Y) is equivalent to Y.
-     (X AND Y) OR (X AND !Y) is equivalent to X.  */
-
-  n = preds->length ();
-  for (i = 0; i < n; i++)
-    {
-      pred_info x, y;
-      pred_chain *a_chain = &(*preds)[i];
-
-      if (a_chain->length () != 2)
-	continue;
-
-      x = (*a_chain)[0];
-      y = (*a_chain)[1];
-
-      for (j = 0; j < n; j++)
-	{
-	  pred_chain *b_chain;
-	  pred_info x2, y2;
-
-	  if (j == i)
-	    continue;
-
-	  b_chain = &(*preds)[j];
-	  if (b_chain->length () != 2)
-	    continue;
-
-	  x2 = (*b_chain)[0];
-	  y2 = (*b_chain)[1];
-
-	  if (pred_equal_p (x, x2) && pred_neg_p (y, y2))
-	    {
-	      /* Kill a_chain.  */
-	      a_chain->release ();
-	      b_chain->release ();
-	      b_chain->safe_push (x);
-	      simplified = true;
-	      break;
-	    }
-	  if (pred_neg_p (x, x2) && pred_equal_p (y, y2))
-	    {
-	      /* Kill a_chain.  */
-	      a_chain->release ();
-	      b_chain->release ();
-	      b_chain->safe_push (y);
-	      simplified = true;
-	      break;
-	    }
-	}
-    }
-  /* Now clean up the chain.  */
-  if (simplified)
-    {
-      for (i = 0; i < n; i++)
-	{
-	  if ((*preds)[i].is_empty ())
-	    continue;
-	  s_preds.safe_push ((*preds)[i]);
-	}
-      preds->release ();
-      (*preds) = s_preds;
-      s_preds = vNULL;
-    }
-
-  return simplified;
-}
-
-/* The helper function implements the rule 2 for the
-   OR predicate PREDS.
-
-   3) x OR (!x AND y) is equivalent to x OR y.  */
-
-static bool
-simplify_preds_3 (pred_chain_union *preds)
-{
-  size_t i, j, n;
-  bool simplified = false;
-
-  /* Now iteratively simplify X OR (!X AND Z ..)
-       into X OR (Z ...).  */
-
-  n = preds->length ();
-  if (n < 2)
-    return false;
-
-  for (i = 0; i < n; i++)
-    {
-      pred_info x;
-      pred_chain *a_chain = &(*preds)[i];
-
-      if (a_chain->length () != 1)
-	continue;
-
-      x = (*a_chain)[0];
-
-      for (j = 0; j < n; j++)
-	{
-	  pred_chain *b_chain;
-	  pred_info x2;
-	  size_t k;
-
-	  if (j == i)
-	    continue;
-
-	  b_chain = &(*preds)[j];
-	  if (b_chain->length () < 2)
-	    continue;
-
-	  for (k = 0; k < b_chain->length (); k++)
-	    {
-	      x2 = (*b_chain)[k];
-	      if (pred_neg_p (x, x2))
-		{
-		  b_chain->unordered_remove (k);
-		  simplified = true;
-		  break;
-		}
-	    }
-	}
-    }
-  return simplified;
-}
-
-/* The helper function implements the rule 4 for the
-   OR predicate PREDS.
-
-   2) ((x AND y) != 0) OR (x != 0 AND y != 0) is equivalent to
-       (x != 0 ANd y != 0).   */
-
-static bool
-simplify_preds_4 (pred_chain_union *preds)
-{
-  size_t i, j, n;
-  bool simplified = false;
-  pred_chain_union s_preds = vNULL;
-  gimple *def_stmt;
-
-  n = preds->length ();
-  for (i = 0; i < n; i++)
-    {
-      pred_info z;
-      pred_chain *a_chain = &(*preds)[i];
-
-      if (a_chain->length () != 1)
-	continue;
-
-      z = (*a_chain)[0];
-
-      if (!is_neq_zero_form_p (z))
-	continue;
-
-      def_stmt = SSA_NAME_DEF_STMT (z.pred_lhs);
-      if (gimple_code (def_stmt) != GIMPLE_ASSIGN)
-	continue;
-
-      if (gimple_assign_rhs_code (def_stmt) != BIT_AND_EXPR)
-	continue;
-
-      for (j = 0; j < n; j++)
-	{
-	  pred_chain *b_chain;
-	  pred_info x2, y2;
-
-	  if (j == i)
-	    continue;
-
-	  b_chain = &(*preds)[j];
-	  if (b_chain->length () != 2)
-	    continue;
-
-	  x2 = (*b_chain)[0];
-	  y2 = (*b_chain)[1];
-	  if (!is_neq_zero_form_p (x2) || !is_neq_zero_form_p (y2))
-	    continue;
-
-	  if ((pred_expr_equal_p (x2, gimple_assign_rhs1 (def_stmt))
-	       && pred_expr_equal_p (y2, gimple_assign_rhs2 (def_stmt)))
-	      || (pred_expr_equal_p (x2, gimple_assign_rhs2 (def_stmt))
-		  && pred_expr_equal_p (y2, gimple_assign_rhs1 (def_stmt))))
-	    {
-	      /* Kill a_chain.  */
-	      a_chain->release ();
-	      simplified = true;
-	      break;
-	    }
-	}
-    }
-  /* Now clean up the chain.  */
-  if (simplified)
-    {
-      for (i = 0; i < n; i++)
-	{
-	  if ((*preds)[i].is_empty ())
-	    continue;
-	  s_preds.safe_push ((*preds)[i]);
-	}
-
-      preds->release ();
-      (*preds) = s_preds;
-      s_preds = vNULL;
-    }
-
-  return simplified;
-}
-
-/* This function simplifies predicates in PREDS.  */
-
-static void
-simplify_preds (pred_chain_union *preds, gimple *use_or_def, bool is_use)
-{
-  size_t i, n;
-  bool changed = false;
-
-  if (dump_file && dump_flags & TDF_DETAILS)
-    {
-      fprintf (dump_file, "[BEFORE SIMPLICATION -- ");
-      dump_predicates (use_or_def, *preds, is_use ? "[USE]:\n" : "[DEF]:\n");
-    }
-
-  for (i = 0; i < preds->length (); i++)
-    simplify_pred (&(*preds)[i]);
-
-  n = preds->length ();
-  if (n < 2)
-    return;
-
-  do
-    {
-      changed = false;
-      if (simplify_preds_2 (preds))
-	changed = true;
-
-      /* Now iteratively simplify X OR (!X AND Z ..)
-       into X OR (Z ...).  */
-      if (simplify_preds_3 (preds))
-	changed = true;
-
-      if (simplify_preds_4 (preds))
-	changed = true;
-    }
-  while (changed);
-
-  return;
-}
-
-/* This is a helper function which attempts to normalize predicate chains
-  by following UD chains.  It basically builds up a big tree of either IOR
-  operations or AND operations, and convert the IOR tree into a
-  pred_chain_union or BIT_AND tree into a pred_chain.
-  Example:
-
-  _3 = _2 RELOP1 _1;
-  _6 = _5 RELOP2 _4;
-  _9 = _8 RELOP3 _7;
-  _10 = _3 | _6;
-  _12 = _9 | _0;
-  _t = _10 | _12;
-
- then _t != 0 will be normalized into a pred_chain_union
-
-   (_2 RELOP1 _1) OR (_5 RELOP2 _4) OR (_8 RELOP3 _7) OR (_0 != 0)
-
- Similarly given,
-
-  _3 = _2 RELOP1 _1;
-  _6 = _5 RELOP2 _4;
-  _9 = _8 RELOP3 _7;
-  _10 = _3 & _6;
-  _12 = _9 & _0;
-
- then _t != 0 will be normalized into a pred_chain:
-   (_2 RELOP1 _1) AND (_5 RELOP2 _4) AND (_8 RELOP3 _7) AND (_0 != 0)
-
-  */
-
-/* This is a helper function that stores a PRED into NORM_PREDS.  */
-
-inline static void
-push_pred (pred_chain_union *norm_preds, pred_info pred)
-{
-  pred_chain pred_chain = vNULL;
-  pred_chain.safe_push (pred);
-  norm_preds->safe_push (pred_chain);
-}
-
-/* A helper function that creates a predicate of the form
-   OP != 0 and push it WORK_LIST.  */
-
-inline static void
-push_to_worklist (tree op, vec<pred_info, va_heap, vl_ptr> *work_list,
-		  hash_set<tree> *mark_set)
-{
-  if (mark_set->contains (op))
-    return;
-  mark_set->add (op);
-
-  pred_info arg_pred;
-  arg_pred.pred_lhs = op;
-  arg_pred.pred_rhs = integer_zero_node;
-  arg_pred.cond_code = NE_EXPR;
-  arg_pred.invert = false;
-  work_list->safe_push (arg_pred);
-}
-
-/* A helper that generates a pred_info from a gimple assignment
-   CMP_ASSIGN with comparison rhs.  */
-
-static pred_info
-get_pred_info_from_cmp (gimple *cmp_assign)
-{
-  pred_info n_pred;
-  n_pred.pred_lhs = gimple_assign_rhs1 (cmp_assign);
-  n_pred.pred_rhs = gimple_assign_rhs2 (cmp_assign);
-  n_pred.cond_code = gimple_assign_rhs_code (cmp_assign);
-  n_pred.invert = false;
-  return n_pred;
-}
-
-/* Returns true if the PHI is a degenerated phi with
-   all args with the same value (relop).  In that case, *PRED
-   will be updated to that value.  */
-
-static bool
-is_degenerated_phi (gimple *phi, pred_info *pred_p)
-{
-  int i, n;
-  tree op0;
-  gimple *def0;
-  pred_info pred0;
-
-  n = gimple_phi_num_args (phi);
-  op0 = gimple_phi_arg_def (phi, 0);
-
-  if (TREE_CODE (op0) != SSA_NAME)
-    return false;
-
-  def0 = SSA_NAME_DEF_STMT (op0);
-  if (gimple_code (def0) != GIMPLE_ASSIGN)
-    return false;
-  if (TREE_CODE_CLASS (gimple_assign_rhs_code (def0)) != tcc_comparison)
-    return false;
-  pred0 = get_pred_info_from_cmp (def0);
-
-  for (i = 1; i < n; ++i)
-    {
-      gimple *def;
-      pred_info pred;
-      tree op = gimple_phi_arg_def (phi, i);
-
-      if (TREE_CODE (op) != SSA_NAME)
-	return false;
-
-      def = SSA_NAME_DEF_STMT (op);
-      if (gimple_code (def) != GIMPLE_ASSIGN)
-	return false;
-      if (TREE_CODE_CLASS (gimple_assign_rhs_code (def)) != tcc_comparison)
-	return false;
-      pred = get_pred_info_from_cmp (def);
-      if (!pred_equal_p (pred, pred0))
-	return false;
-    }
-
-  *pred_p = pred0;
-  return true;
-}
-
-/* Normalize one predicate PRED
-   1) if PRED can no longer be normlized, put it into NORM_PREDS.
-   2) otherwise if PRED is of the form x != 0, follow x's definition
-      and put normalized predicates into WORK_LIST.  */
-
-static void
-normalize_one_pred_1 (pred_chain_union *norm_preds,
-		      pred_chain *norm_chain,
-		      pred_info pred,
-		      enum tree_code and_or_code,
-		      vec<pred_info, va_heap, vl_ptr> *work_list,
-		      hash_set<tree> *mark_set)
-{
-  if (!is_neq_zero_form_p (pred))
-    {
-      if (and_or_code == BIT_IOR_EXPR)
-	push_pred (norm_preds, pred);
-      else
-	norm_chain->safe_push (pred);
-      return;
-    }
-
-  gimple *def_stmt = SSA_NAME_DEF_STMT (pred.pred_lhs);
-
-  if (gimple_code (def_stmt) == GIMPLE_PHI
-      && is_degenerated_phi (def_stmt, &pred))
-    work_list->safe_push (pred);
-  else if (gimple_code (def_stmt) == GIMPLE_PHI && and_or_code == BIT_IOR_EXPR)
-    {
-      int i, n;
-      n = gimple_phi_num_args (def_stmt);
-
-      /* If we see non zero constant, we should punt.  The predicate
-       * should be one guarding the phi edge.  */
-      for (i = 0; i < n; ++i)
-	{
-	  tree op = gimple_phi_arg_def (def_stmt, i);
-	  if (TREE_CODE (op) == INTEGER_CST && !integer_zerop (op))
-	    {
-	      push_pred (norm_preds, pred);
-	      return;
-	    }
-	}
-
-      for (i = 0; i < n; ++i)
-	{
-	  tree op = gimple_phi_arg_def (def_stmt, i);
-	  if (integer_zerop (op))
-	    continue;
-
-	  push_to_worklist (op, work_list, mark_set);
-	}
-    }
-  else if (gimple_code (def_stmt) != GIMPLE_ASSIGN)
-    {
-      if (and_or_code == BIT_IOR_EXPR)
-	push_pred (norm_preds, pred);
-      else
-	norm_chain->safe_push (pred);
-    }
-  else if (gimple_assign_rhs_code (def_stmt) == and_or_code)
-    {
-      /* Avoid splitting up bit manipulations like x & 3 or y | 1.  */
-      if (is_gimple_min_invariant (gimple_assign_rhs2 (def_stmt)))
-	{
-	  /* But treat x & 3 as condition.  */
-	  if (and_or_code == BIT_AND_EXPR)
-	    {
-	      pred_info n_pred;
-	      n_pred.pred_lhs = gimple_assign_rhs1 (def_stmt);
-	      n_pred.pred_rhs = gimple_assign_rhs2 (def_stmt);
-	      n_pred.cond_code = and_or_code;
-	      n_pred.invert = false;
-	      norm_chain->safe_push (n_pred);
-	    }
-	}
-      else
-	{
-	  push_to_worklist (gimple_assign_rhs1 (def_stmt), work_list, mark_set);
-	  push_to_worklist (gimple_assign_rhs2 (def_stmt), work_list, mark_set);
-	}
-    }
-  else if (TREE_CODE_CLASS (gimple_assign_rhs_code (def_stmt))
-	   == tcc_comparison)
-    {
-      pred_info n_pred = get_pred_info_from_cmp (def_stmt);
-      if (and_or_code == BIT_IOR_EXPR)
-	push_pred (norm_preds, n_pred);
-      else
-	norm_chain->safe_push (n_pred);
-    }
-  else
-    {
-      if (and_or_code == BIT_IOR_EXPR)
-	push_pred (norm_preds, pred);
-      else
-	norm_chain->safe_push (pred);
-    }
-}
-
-/* Normalize PRED and store the normalized predicates into NORM_PREDS.  */
-
-static void
-normalize_one_pred (pred_chain_union *norm_preds, pred_info pred)
-{
-  vec<pred_info, va_heap, vl_ptr> work_list = vNULL;
-  enum tree_code and_or_code = ERROR_MARK;
-  pred_chain norm_chain = vNULL;
-
-  if (!is_neq_zero_form_p (pred))
-    {
-      push_pred (norm_preds, pred);
-      return;
-    }
-
-  gimple *def_stmt = SSA_NAME_DEF_STMT (pred.pred_lhs);
-  if (gimple_code (def_stmt) == GIMPLE_ASSIGN)
-    and_or_code = gimple_assign_rhs_code (def_stmt);
-  if (and_or_code != BIT_IOR_EXPR && and_or_code != BIT_AND_EXPR)
-    {
-      if (TREE_CODE_CLASS (and_or_code) == tcc_comparison)
-	{
-	  pred_info n_pred = get_pred_info_from_cmp (def_stmt);
-	  push_pred (norm_preds, n_pred);
-	}
-      else
-	push_pred (norm_preds, pred);
-      return;
-    }
-
-  work_list.safe_push (pred);
-  hash_set<tree> mark_set;
-
-  while (!work_list.is_empty ())
-    {
-      pred_info a_pred = work_list.pop ();
-      normalize_one_pred_1 (norm_preds, &norm_chain, a_pred, and_or_code,
-			    &work_list, &mark_set);
-    }
-  if (and_or_code == BIT_AND_EXPR)
-    norm_preds->safe_push (norm_chain);
-
-  work_list.release ();
-}
-
-static void
-normalize_one_pred_chain (pred_chain_union *norm_preds, pred_chain one_chain)
-{
-  vec<pred_info, va_heap, vl_ptr> work_list = vNULL;
-  hash_set<tree> mark_set;
-  pred_chain norm_chain = vNULL;
-  size_t i;
-
-  for (i = 0; i < one_chain.length (); i++)
-    {
-      work_list.safe_push (one_chain[i]);
-      mark_set.add (one_chain[i].pred_lhs);
-    }
-
-  while (!work_list.is_empty ())
-    {
-      pred_info a_pred = work_list.pop ();
-      normalize_one_pred_1 (0, &norm_chain, a_pred, BIT_AND_EXPR, &work_list,
-			    &mark_set);
-    }
-
-  norm_preds->safe_push (norm_chain);
-  work_list.release ();
-}
-
-/* Normalize predicate chains PREDS and returns the normalized one.  */
-
-static pred_chain_union
-normalize_preds (pred_chain_union preds, gimple *use_or_def, bool is_use)
-{
-  pred_chain_union norm_preds = vNULL;
-  size_t n = preds.length ();
-  size_t i;
-
-  if (dump_file && dump_flags & TDF_DETAILS)
-    {
-      fprintf (dump_file, "[BEFORE NORMALIZATION --");
-      dump_predicates (use_or_def, preds, is_use ? "[USE]:\n" : "[DEF]:\n");
-    }
-
-  for (i = 0; i < n; i++)
-    {
-      if (preds[i].length () != 1)
-	normalize_one_pred_chain (&norm_preds, preds[i]);
-      else
-	{
-	  normalize_one_pred (&norm_preds, preds[i][0]);
-	  preds[i].release ();
-	}
-    }
-
-  if (dump_file)
-    {
-      fprintf (dump_file, "[AFTER NORMALIZATION -- ");
-      dump_predicates (use_or_def, norm_preds,
-		       is_use ? "[USE]:\n" : "[DEF]:\n");
-    }
-
-  destroy_predicate_vecs (&preds);
-  return norm_preds;
-}
-
-/* Return TRUE if PREDICATE can be invalidated by any individual
-   predicate in USE_GUARD.  */
-
-static bool
-can_one_predicate_be_invalidated_p (pred_info predicate,
-				    pred_chain use_guard)
-{
-  if (dump_file && dump_flags & TDF_DETAILS)
-    {
-      fprintf (dump_file, "Testing if this predicate: ");
-      dump_pred_info (predicate);
-      fprintf (dump_file, "\n...can be invalidated by a USE guard of: ");
-      dump_pred_chain (use_guard);
-    }
-  for (size_t i = 0; i < use_guard.length (); ++i)
-    {
-      /* NOTE: This is a very simple check, and only understands an
-	 exact opposite.  So, [i == 0] is currently only invalidated
-	 by [.NOT. i == 0] or [i != 0].  Ideally we should also
-	 invalidate with say [i > 5] or [i == 8].  There is certainly
-	 room for improvement here.  */
-      if (pred_neg_p (predicate, use_guard[i]))
-	{
-	  if (dump_file && dump_flags & TDF_DETAILS)
-	    {
-	      fprintf (dump_file, "  Predicate was invalidated by: ");
-	      dump_pred_info (use_guard[i]);
-	      fputc ('\n', dump_file);
-	    }
-	  return true;
-	}
-    }
-  return false;
-}
-
-/* Return TRUE if all predicates in UNINIT_PRED are invalidated by
-   USE_GUARD being true.  */
-
-static bool
-can_chain_union_be_invalidated_p (pred_chain_union uninit_pred,
-				  pred_chain use_guard)
-{
-  if (uninit_pred.is_empty ())
-    return false;
-  if (dump_file && dump_flags & TDF_DETAILS)
-    dump_predicates (NULL, uninit_pred,
-		     "Testing if anything here can be invalidated: ");
-  for (size_t i = 0; i < uninit_pred.length (); ++i)
-    {
-      pred_chain c = uninit_pred[i];
-      size_t j;
-      for (j = 0; j < c.length (); ++j)
-	if (can_one_predicate_be_invalidated_p (c[j], use_guard))
-	  break;
-
-      /* If we were unable to invalidate any predicate in C, then there
-	 is a viable path from entry to the PHI where the PHI takes
-	 an uninitialized value and continues to a use of the PHI.  */
-      if (j == c.length ())
-	return false;
-    }
-  return true;
-}
-
-/* Return TRUE if none of the uninitialized operands in UNINT_OPNDS
-   can actually happen if we arrived at a use for PHI.
-
-   PHI_USE_GUARDS are the guard conditions for the use of the PHI.  */
-
-static bool
-uninit_uses_cannot_happen (gphi *phi, unsigned uninit_opnds,
-			   pred_chain_union phi_use_guards)
-{
-  unsigned phi_args = gimple_phi_num_args (phi);
-  if (phi_args > max_phi_args)
-    return false;
-
-  /* PHI_USE_GUARDS are OR'ed together.  If we have more than one
-     possible guard, there's no way of knowing which guard was true.
-     Since we need to be absolutely sure that the uninitialized
-     operands will be invalidated, bail.  */
-  if (phi_use_guards.length () != 1)
-    return false;
-
-  /* Look for the control dependencies of all the uninitialized
-     operands and build guard predicates describing them.  */
-  pred_chain_union uninit_preds;
-  bool ret = true;
-  for (unsigned i = 0; i < phi_args; ++i)
-    {
-      if (!MASK_TEST_BIT (uninit_opnds, i))
-	continue;
-
-      edge e = gimple_phi_arg_edge (phi, i);
-      vec<edge> dep_chains[MAX_NUM_CHAINS];
-      auto_vec<edge, MAX_CHAIN_LEN + 1> cur_chain;
-      size_t num_chains = 0;
-      int num_calls = 0;
-
-      /* Build the control dependency chain for uninit operand `i'...  */
-      uninit_preds = vNULL;
-      if (!compute_control_dep_chain (ENTRY_BLOCK_PTR_FOR_FN (cfun),
-				      e->src, dep_chains, &num_chains,
-				      &cur_chain, &num_calls))
-	{
-	  ret = false;
-	  break;
-	}
-      /* ...and convert it into a set of predicates.  */
-      bool has_valid_preds
-	= convert_control_dep_chain_into_preds (dep_chains, num_chains,
-						&uninit_preds);
-      for (size_t j = 0; j < num_chains; ++j)
-	dep_chains[j].release ();
-      if (!has_valid_preds)
-	{
-	  ret = false;
-	  break;
-	}
-      simplify_preds (&uninit_preds, NULL, false);
-      uninit_preds = normalize_preds (uninit_preds, NULL, false);
-
-      /* Can the guard for this uninitialized operand be invalidated
-	 by the PHI use?  */
-      if (!can_chain_union_be_invalidated_p (uninit_preds, phi_use_guards[0]))
-	{
-	  ret = false;
-	  break;
-	}
-    }
-  destroy_predicate_vecs (&uninit_preds);
-  return ret;
-}
-
-/* Computes the predicates that guard the use and checks
-   if the incoming paths that have empty (or possibly
-   empty) definition can be pruned/filtered.  The function returns
-   true if it can be determined that the use of PHI's def in
-   USE_STMT is guarded with a predicate set not overlapping with
-   predicate sets of all runtime paths that do not have a definition.
-
-   Returns false if it is not or it cannot be determined.  USE_BB is
-   the bb of the use (for phi operand use, the bb is not the bb of
-   the phi stmt, but the src bb of the operand edge).
-
-   UNINIT_OPNDS is a bit vector.  If an operand of PHI is uninitialized, the
-   corresponding bit in the vector is 1.  VISITED_PHIS is a pointer
-   set of phis being visited.
-
-   *DEF_PREDS contains the (memoized) defining predicate chains of PHI.
-   If *DEF_PREDS is the empty vector, the defining predicate chains of
-   PHI will be computed and stored into *DEF_PREDS as needed.
-
-   VISITED_PHIS is a pointer set of phis being visited.  */
-
-static bool
-is_use_properly_guarded (gimple *use_stmt,
-			 basic_block use_bb,
-			 gphi *phi,
-			 unsigned uninit_opnds,
-			 pred_chain_union *def_preds,
-			 hash_set<gphi *> *visited_phis)
-{
-  basic_block phi_bb;
-  pred_chain_union preds = vNULL;
-  bool has_valid_preds = false;
-  bool is_properly_guarded = false;
-
-  if (visited_phis->add (phi))
-    return false;
-
-  phi_bb = gimple_bb (phi);
-
-  if (is_non_loop_exit_postdominating (use_bb, phi_bb))
-    return false;
-
-  has_valid_preds = find_predicates (&preds, phi_bb, use_bb);
-
-  if (!has_valid_preds)
-    {
-      destroy_predicate_vecs (&preds);
-      return false;
-    }
-
-  /* Try to prune the dead incoming phi edges.  */
-  is_properly_guarded
-    = use_pred_not_overlap_with_undef_path_pred (preds, phi, uninit_opnds,
-						 visited_phis);
-
-  /* We might be able to prove that if the control dependencies
-     for UNINIT_OPNDS are true, that the control dependencies for
-     USE_STMT can never be true.  */
-  if (!is_properly_guarded)
-    is_properly_guarded |= uninit_uses_cannot_happen (phi, uninit_opnds,
-						      preds);
-
-  if (is_properly_guarded)
-    {
-      destroy_predicate_vecs (&preds);
-      return true;
-    }
-
-  if (def_preds->is_empty ())
-    {
-      has_valid_preds = find_def_preds (def_preds, phi);
-
-      if (!has_valid_preds)
-	{
-	  destroy_predicate_vecs (&preds);
-	  return false;
-	}
-
-      simplify_preds (def_preds, phi, false);
-      *def_preds = normalize_preds (*def_preds, phi, false);
-    }
-
-  simplify_preds (&preds, use_stmt, true);
-  preds = normalize_preds (preds, use_stmt, true);
-
-  is_properly_guarded = is_superset_of (*def_preds, preds);
-
-  destroy_predicate_vecs (&preds);
-  return is_properly_guarded;
-}
-
-/* Searches through all uses of a potentially
-   uninitialized variable defined by PHI and returns a use
-   statement if the use is not properly guarded.  It returns
-   NULL if all uses are guarded.  UNINIT_OPNDS is a bitvector
-   holding the position(s) of uninit PHI operands.  WORKLIST
-   is the vector of candidate phis that may be updated by this
-   function.  ADDED_TO_WORKLIST is the pointer set tracking
-   if the new phi is already in the worklist.  */
-
-static gimple *
-find_uninit_use (gphi *phi, unsigned uninit_opnds,
-		 vec<gphi *> *worklist,
-		 hash_set<gphi *> *added_to_worklist)
-{
-  tree phi_result;
-  use_operand_p use_p;
-  gimple *use_stmt;
-  imm_use_iterator iter;
-  pred_chain_union def_preds = vNULL;
-  gimple *ret = NULL;
-
-  phi_result = gimple_phi_result (phi);
-
-  FOR_EACH_IMM_USE_FAST (use_p, iter, phi_result)
-    {
-      basic_block use_bb;
-
-      use_stmt = USE_STMT (use_p);
-      if (is_gimple_debug (use_stmt))
-	continue;
-
-      if (gphi *use_phi = dyn_cast<gphi *> (use_stmt))
-	use_bb = gimple_phi_arg_edge (use_phi,
-				      PHI_ARG_INDEX_FROM_USE (use_p))->src;
-      else
-	use_bb = gimple_bb (use_stmt);
-
-      hash_set<gphi *> visited_phis;
-      if (is_use_properly_guarded (use_stmt, use_bb, phi, uninit_opnds,
-				   &def_preds, &visited_phis))
-	continue;
-
-      if (dump_file && (dump_flags & TDF_DETAILS))
-	{
-	  fprintf (dump_file, "[CHECK]: Found unguarded use: ");
-	  print_gimple_stmt (dump_file, use_stmt, 0);
-	}
-      /* Found one real use, return.  */
-      if (gimple_code (use_stmt) != GIMPLE_PHI)
-	{
-	  ret = use_stmt;
-	  break;
-	}
-
-      /* Found a phi use that is not guarded,
-	 add the phi to the worklist.  */
-      if (!added_to_worklist->add (as_a<gphi *> (use_stmt)))
-	{
-	  if (dump_file && (dump_flags & TDF_DETAILS))
-	    {
-	      fprintf (dump_file, "[WORKLIST]: Update worklist with phi: ");
-	      print_gimple_stmt (dump_file, use_stmt, 0);
-	    }
-
-	  worklist->safe_push (as_a<gphi *> (use_stmt));
-	  possibly_undefined_names->add (phi_result);
-	}
-    }
-
-  destroy_predicate_vecs (&def_preds);
-  return ret;
-}
-
-/* Look for inputs to PHI that are SSA_NAMEs that have empty definitions
-   and gives warning if there exists a runtime path from the entry to a
-   use of the PHI def that does not contain a definition.  In other words,
-   the warning is on the real use.  The more dead paths that can be pruned
-   by the compiler, the fewer false positives the warning is.  WORKLIST
-   is a vector of candidate phis to be examined.  ADDED_TO_WORKLIST is
-   a pointer set tracking if the new phi is added to the worklist or not.  */
-
-static void
-warn_uninitialized_phi (gphi *phi, vec<gphi *> *worklist,
-			hash_set<gphi *> *added_to_worklist)
-{
-  /* Don't look at virtual operands.  */
-  if (virtual_operand_p (gimple_phi_result (phi)))
-    return;
-
-  unsigned uninit_opnds = compute_uninit_opnds_pos (phi);
-  if (MASK_EMPTY (uninit_opnds))
-    return;
-
-  if (dump_file && (dump_flags & TDF_DETAILS))
-    {
-      fprintf (dump_file, "[CHECK]: examining phi: ");
-      print_gimple_stmt (dump_file, phi, 0);
-    }
-
-  /* Now check if we have any use of the value without proper guard.  */
-  gimple *uninit_use_stmt = find_uninit_use (phi, uninit_opnds,
-					     worklist, added_to_worklist);
-
-  /* All uses are properly guarded.  */
-  if (!uninit_use_stmt)
-    return;
-
-  int phiarg_index = MASK_FIRST_SET_BIT (uninit_opnds);
-  tree uninit_op = gimple_phi_arg_def (phi, phiarg_index);
-  if (SSA_NAME_VAR (uninit_op) == NULL_TREE)
-    return;
-
-  location_t phi_arg_loc = gimple_phi_arg_location (phi, phiarg_index);
-  warn_uninit (OPT_Wmaybe_uninitialized, uninit_op,
-	       SSA_NAME_VAR (uninit_op),
-	       "%qD may be used uninitialized in this function",
-	       uninit_use_stmt, phi_arg_loc);
-}
-
-static bool
-gate_warn_uninitialized (void)
-{
-  return warn_uninitialized || warn_maybe_uninitialized;
-}
-
-namespace {
-
-const pass_data pass_data_late_warn_uninitialized =
-{
-  GIMPLE_PASS, /* type */
-  "uninit", /* name */
-  OPTGROUP_NONE, /* optinfo_flags */
-  TV_NONE, /* tv_id */
-  PROP_ssa, /* properties_required */
-  0, /* properties_provided */
-  0, /* properties_destroyed */
-  0, /* todo_flags_start */
-  0, /* todo_flags_finish */
-};
-
-class pass_late_warn_uninitialized : public gimple_opt_pass
-{
-public:
-  pass_late_warn_uninitialized (gcc::context *ctxt)
-    : gimple_opt_pass (pass_data_late_warn_uninitialized, ctxt)
-  {}
-
-  /* opt_pass methods: */
-  opt_pass *clone () { return new pass_late_warn_uninitialized (m_ctxt); }
-  virtual bool gate (function *) { return gate_warn_uninitialized (); }
-  virtual unsigned int execute (function *);
-
-}; // class pass_late_warn_uninitialized
-
-unsigned int
-pass_late_warn_uninitialized::execute (function *fun)
-{
-  basic_block bb;
-  gphi_iterator gsi;
-  vec<gphi *> worklist = vNULL;
-
-  calculate_dominance_info (CDI_DOMINATORS);
-  calculate_dominance_info (CDI_POST_DOMINATORS);
-  /* Re-do the plain uninitialized variable check, as optimization may have
-     straightened control flow.  Do this first so that we don't accidentally
-     get a "may be" warning when we'd have seen an "is" warning later.  */
-  warn_uninitialized_vars (/*warn_maybe_uninitialized=*/1);
-
-  timevar_push (TV_TREE_UNINIT);
-
-  possibly_undefined_names = new hash_set<tree>;
-  hash_set<gphi *> added_to_worklist;
-
-  /* Initialize worklist  */
-  FOR_EACH_BB_FN (bb, fun)
-    for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-      {
-	gphi *phi = gsi.phi ();
-	size_t n, i;
-
-	n = gimple_phi_num_args (phi);
+  /* Initialize worklist  */
+  FOR_EACH_BB_FN (bb, fun)
+    for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      {
+	gphi *phi = gsi.phi ();
 
 	/* Don't look at virtual operands.  */
 	if (virtual_operand_p (gimple_phi_result (phi)))
 	  continue;
 
-	for (i = 0; i < n; ++i)
+	unsigned n = gimple_phi_num_args (phi);
+	for (unsigned i = 0; i < n; ++i)
 	  {
 	    tree op = gimple_phi_arg_def (phi, i);
 	    if (TREE_CODE (op) == SSA_NAME && uninit_undefined_value_p (op))
@@ -3292,7 +1211,8 @@  pass_late_warn_uninitialized::execute (function *fun)
 		added_to_worklist.add (phi);
 		if (dump_file && (dump_flags & TDF_DETAILS))
 		  {
-		    fprintf (dump_file, "[WORKLIST]: add to initial list: ");
+		    fprintf (dump_file, "[WORKLIST]: add to initial list "
+			     "for operand %u of: ", i);
 		    print_gimple_stmt (dump_file, phi, 0);
 		  }
 		break;
@@ -3312,6 +1232,12 @@  pass_late_warn_uninitialized::execute (function *fun)
   possibly_undefined_names = NULL;
   free_dominance_info (CDI_POST_DOMINATORS);
   timevar_pop (TV_TREE_UNINIT);
+}
+
+unsigned int
+pass_late_warn_uninitialized::execute (function *fun)
+{
+  execute_late_warn_uninitialized (fun);
   return 0;
 }