https://gcc.gnu.org/g:cfc10ee040798637c72487435d0ab8668e05c386
commit cfc10ee040798637c72487435d0ab8668e05c386 Author: Alexandre Oliva <ol...@gnu.org> Date: Fri Sep 13 02:13:50 2024 -0300 relax ifcombine to accept vuses Diff: --- gcc/config/i386/t-i386 | 2 ++ gcc/testsuite/gcc.dg/field-merge-6.c | 25 +++++++++++++++++++++++++ gcc/tree-ssa-ifcombine.cc | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/gcc/config/i386/t-i386 b/gcc/config/i386/t-i386 index bf4ae109af98..1b904787ec62 100644 --- a/gcc/config/i386/t-i386 +++ b/gcc/config/i386/t-i386 @@ -79,3 +79,5 @@ s-i386-bt: $(srcdir)/config/i386/i386-builtin-types.awk \ $(AWK) -f $^ > tmp-bt.inc $(SHELL) $(srcdir)/../move-if-change tmp-bt.inc i386-builtin-types.inc $(STAMP) $@ + +insn-attrtab.o-warn = -Wno-error diff --git a/gcc/testsuite/gcc.dg/field-merge-6.c b/gcc/testsuite/gcc.dg/field-merge-6.c new file mode 100644 index 000000000000..c42bed927c66 --- /dev/null +++ b/gcc/testsuite/gcc.dg/field-merge-6.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-O" } */ +/* { dg-shouldfail } */ + +struct s { + char a, b; + struct s *p; +}; + +struct s a = { 0, 1, 0 }; +struct s b = { 0, 0, &a }; + +int f () { + /* Check that the third compare won't be pulled ahead of the second one and + prevent the NULL pointer dereference that should cause the execution to + fail. */ + return (a->a != b->a + || b->p->b != a->p->a + || a->b != b->b); +} + +int main() { + f (); + return 0; +} diff --git a/gcc/tree-ssa-ifcombine.cc b/gcc/tree-ssa-ifcombine.cc index 61480e5fa894..7678c87e0170 100644 --- a/gcc/tree-ssa-ifcombine.cc +++ b/gcc/tree-ssa-ifcombine.cc @@ -129,7 +129,7 @@ bb_no_side_effects_p (basic_block bb) enum tree_code rhs_code; if (gimple_has_side_effects (stmt) || gimple_could_trap_p (stmt) - || gimple_vuse (stmt) + /* || gimple_vuse (stmt) */ /* We need to rewrite stmts with undefined overflow to use unsigned arithmetic but cannot do so for signed division. */ || ((ass = dyn_cast <gassign *> (stmt))