diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-12-13 19:25:33 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-12-13 19:28:07 +0100 |
commit | 49ec63666e086853401021e686f0aa4d285ce9dc (patch) | |
tree | e5669d886633bfa6ee97f838ccbac65b88a7c0f0 /gcc/testsuite | |
parent | 3cc4e183f12e962678c70f2c3d476c748a82c29e (diff) | |
download | gcc-49ec63666e086853401021e686f0aa4d285ce9dc.zip gcc-49ec63666e086853401021e686f0aa4d285ce9dc.tar.gz gcc-49ec63666e086853401021e686f0aa4d285ce9dc.tar.bz2 |
widening_mul: Fix a > ~b to .ADD_OVERFLOW optimization [PR98256]
Unfortunately, my latest tree-ssa-math-opts.c patch broke the following
testcase. The problem is that the code is adding .ADD_OVERFLOW or
.SUB_OVERFLOW before or after the stmt on which the function has been
called, which is normally a addition or subtraction that has all the
operands.
But in the a > ~b optimization that stmt is the ~b stmt and the other
comparison operand might be defined only after that ~b stmt, so we can't
insert the .ADD_OVERFLOW next to ~b that we want to delete, but need to
insert it before the a > temp comparison that uses it; and in that case
when removing the BIT_NOT_EXPR stmt we need to ensure the caller doesn't do
gsi_next because gsi_remove already points the iterator to the next stmt.
2020-12-13 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/98256
* tree-ssa-math-opts.c (match_uaddsub_overflow): For BIT_NOT_EXPR,
only handle a single use, and insert .ADD_OVERFLOW before the
comparison rather than after the BIT_NOT_EXPR. Return true iff
it is BIT_NOT_EXPR and it has been removed.
(math_opts_dom_walker::after_dom_children) <case BIT_NOT_EXPR>:
If match_uaddsub_overflow returned true, continue instead of break.
* gcc.c-torture/compile/pr98256.c: New test.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr98256.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr98256.c b/gcc/testsuite/gcc.c-torture/compile/pr98256.c new file mode 100644 index 0000000..44839c7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr98256.c @@ -0,0 +1,9 @@ +/* PR tree-optimization/98256 */ + +unsigned a, b; + +int +foo (void) +{ + return !!(~a / b); +} |