tree-optimization/107919 - uninit diagnostic predicate simplification
authorRichard Biener <rguenther@suse.de>
Wed, 30 Nov 2022 09:55:03 +0000 (10:55 +0100)
committerRichard Biener <rguenther@suse.de>
Wed, 30 Nov 2022 11:00:56 +0000 (12:00 +0100)
commit9500877d05c56cef7bfbdcecaab3b1af2610bff3
tree060d420699da00ccf5c95ca0a34bec48ec781143
parent7716ee1e90412f785cba20acffd59fc7461302cb
tree-optimization/107919 - uninit diagnostic predicate simplification

We fail to simplify

        ((_145 != 0B) AND (_531 == 2) AND (_109 == 0))
        OR ((NOT (_145 != 0B)) AND (_531 == 2) AND (_109 == 0))
        OR ((NOT (_531 == 2)) AND (_109 == 0))

because the existing simplification of !A && B || A && B is implemented
too simplistic.  The following re-implements that which fixes the
bogus uninit diagnostic when using -O1 but not yet at -O2.

PR tree-optimization/107919
* gimple-predicate-analysis.cc (predicate::simplify_2):
Handle predicates of arbitrary length.

* g++.dg/warn/Wuninitialized-pr107919-1.C: New testcase.
gcc/gimple-predicate-analysis.cc
gcc/testsuite/g++.dg/warn/Wuninitialized-pr107919-1.C [new file with mode: 0644]