diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-11-25 10:47:24 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-11-25 10:47:24 +0100 |
commit | 94912212d3d1be0b1c490e9b5f45165ef5f30d8a (patch) | |
tree | cdecb377c7d49fce020c30ea8ae0cbae21ddc765 /gcc/gimple-range-path.cc | |
parent | 531dae29a67e915a145d908bd2f46d22bc369c11 (diff) | |
download | gcc-94912212d3d1be0b1c490e9b5f45165ef5f30d8a.zip gcc-94912212d3d1be0b1c490e9b5f45165ef5f30d8a.tar.gz gcc-94912212d3d1be0b1c490e9b5f45165ef5f30d8a.tar.bz2 |
match.pd: Fix up the recent bitmask_inv_cst_vector_p simplification [PR103417]
The following testcase is miscompiled since the r12-5489-g0888d6bbe97e10
changes.
The simplification triggers on
(x & 4294967040U) >= 0U
and turns it into:
x <= 255U
which is incorrect, it should fold to 1 because unsigned >= 0U is always
true and normally the
/* Non-equality compare simplifications from fold_binary */
(if (wi::to_wide (cst) == min)
(if (cmp == GE_EXPR)
{ constant_boolean_node (true, type); })
simplification folds that, but this simplification was done earlier.
The simplification correctly doesn't include lt which has the same
reason why it shouldn't be handled, we'll fold it to 0 elsewhere.
But, IMNSHO while it isn't incorrect to handle le and gt there, it is
unnecessary. Because (x & cst) <= 0U and (x & cst) > 0U should
never appear, again in
/* Non-equality compare simplifications from fold_binary */
we have a simplification for it:
(if (cmp == LE_EXPR)
(eq @2 @1))
(if (cmp == GT_EXPR)
(ne @2 @1))))
This is done for
(cmp (convert?@2 @0) uniform_integer_cst_p@1)
and so should be done for both integers and vectors.
As the bitmask_inv_cst_vector_p simplification only handles
eq and ne for signed types, I think it can be simplified to just
following patch.
2021-11-25 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/103417
* match.pd ((X & Y) CMP 0): Only handle eq and ne. Commonalize
common tests.
* gcc.c-torture/execute/pr103417.c: New test.
Diffstat (limited to 'gcc/gimple-range-path.cc')
0 files changed, 0 insertions, 0 deletions