[gcc(refs/users/aoliva/heads/testme)] relax ifcombine to accept vuses
Alexandre Oliva
aoliva@gcc.gnu.org
Sat Sep 14 00:59:46 GMT 2024
https://gcc.gnu.org/g:7b7dfff4b174765248fcf275dc8fde9c78352ad8
commit 7b7dfff4b174765248fcf275dc8fde9c78352ad8
Author: Alexandre Oliva <oliva@gnu.org>
Date: Fri Sep 13 21:43:15 2024 -0300
relax ifcombine to accept vuses
Diff:
---
gcc/config/i386/t-i386 | 2 ++
gcc/testsuite/gcc.dg/field-merge-6.c | 26 ++++++++++++++++++++++++++
gcc/tree-ssa-ifcombine.cc | 2 +-
3 files changed, 29 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..7fd48a138d14
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/field-merge-6.c
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+/* { dg-options "-O" } */
+/* { dg-shouldfail } */
+
+/* Check that the third compare won't be pulled ahead of the second one and
+ prevent, which would prevent the NULL pointer dereference that should cause
+ the execution to fail. */
+
+struct s {
+ char a, b;
+ int *p;
+};
+
+struct s a = { 0, 1, 0 };
+struct s b = { 0, 0, 0 };
+
+int f () {
+ return (a.a != b.a
+ || *b.p != *a.p
+ || 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))
More information about the Gcc-cvs
mailing list