public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/94234] New: missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1))
@ 2020-03-20 11:14 fxue at os dot amperecomputing.com
2020-03-20 14:16 ` [Bug tree-optimization/94234] " rguenth at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: fxue at os dot amperecomputing.com @ 2020-03-20 11:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94234
Bug ID: 94234
Summary: missed ccp folding for (addr + 8 * n) - (addr + 8 * (n
- 1))
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: fxue at os dot amperecomputing.com
Target Milestone: ---
CCP could not fold the following expression to a constant "8":
size_t foo (char *a, size_t n)
{
char *b1 = a + 8 * n;
char *b2 = a + 8 * (n - 1);
return b1 - b2;
}
But if we change b1 and b2 to integer type, folding happens.
size_t foo (char *a, size_t n)
{
size_t b1 = (size_t)(a + 8 * n);
size_t b2 = (size_t)(a + 8 * (n - 1));
return b1 - b2;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/94234] missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1))
2020-03-20 11:14 [Bug tree-optimization/94234] New: missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1)) fxue at os dot amperecomputing.com
@ 2020-03-20 14:16 ` rguenth at gcc dot gnu.org
2020-03-20 15:50 ` glisse at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-03-20 14:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94234
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2020-03-20
Keywords| |missed-optimization
Version|unknown |10.0
Status|UNCONFIRMED |NEW
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. Might be also a regression since POINTER_DIFF_EXPR introduction.
We have
(simplify
(pointer_diff (pointer_plus @@0 @1) (pointer_plus @0 @2))
/* The second argument of pointer_plus must be interpreted as signed, and
thus sign-extended if necessary. */
(with { tree stype = signed_type_for (TREE_TYPE (@1)); }
/* Use view_convert instead of convert here, as POINTER_PLUS_EXPR
second arg is unsigned even when we need to consider it as signed,
we don't want to diagnose overflow here. */
(minus (convert (view_convert:stype @1))
(convert (view_convert:stype @2)))))))
which triggers here but appearantly the resulting minus isn't simplified.
_1 = n_5(D) * 8;
b1_7 = a_6(D) + _1;
_2 = n_5(D) + 18446744073709551615;
_3 = _2 * 8;
b2_8 = a_6(D) + _3;
and we need to simplify _1 - _3. Possibly the excessive conversions above
mess with the constraint of CCP not wanting new stmts. You can see what
forwprop does which applies all foldings possible and computes:
_1 = n_5(D) * 8;
_2 = n_5(D) + 18446744073709551615;
_3 = _2 * 8;
_11 = (signed long) _1;
_12 = (signed long) _3;
_4 = _11 - _12;
_9 = (long unsigned int) _4;
return _9;
I don't think we have match.pd patterns simplifying that.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/94234] missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1))
2020-03-20 11:14 [Bug tree-optimization/94234] New: missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1)) fxue at os dot amperecomputing.com
2020-03-20 14:16 ` [Bug tree-optimization/94234] " rguenth at gcc dot gnu.org
@ 2020-03-20 15:50 ` glisse at gcc dot gnu.org
2020-08-19 14:30 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: glisse at gcc dot gnu.org @ 2020-03-20 15:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94234
--- Comment #2 from Marc Glisse <glisse at gcc dot gnu.org> ---
The closest we have is
/* (A * C) +- (B * C) -> (A+-B) * C and (A * C) +- A -> A * (C+-1).
which does not handle conversions, although it should be possible to add them.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/94234] missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1))
2020-03-20 11:14 [Bug tree-optimization/94234] New: missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1)) fxue at os dot amperecomputing.com
2020-03-20 14:16 ` [Bug tree-optimization/94234] " rguenth at gcc dot gnu.org
2020-03-20 15:50 ` glisse at gcc dot gnu.org
@ 2020-08-19 14:30 ` cvs-commit at gcc dot gnu.org
2020-09-15 3:15 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-19 14:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94234
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Feng Xue <fxue@gcc.gnu.org>:
https://gcc.gnu.org/g:459f6f68a75fe88e7c8309ca8ad3244a532b0d8e
commit r11-2764-g459f6f68a75fe88e7c8309ca8ad3244a532b0d8e
Author: Feng Xue <fxue@os.amperecomputing.com>
Date: Mon Jun 1 11:57:35 2020 +0800
tree-optimization/94234 - add pattern for ptr-diff on addresses with same
offset
2020-08-19 Feng Xue <fxue@os.amperecomputing.com>
gcc/
PR tree-optimization/94234
* match.pd ((PTR_A + OFF) - (PTR_B + OFF)) -> (PTR_A - PTR_B): New
simplification.
gcc/testsuite/
PR tree-optimization/94234
* gcc.dg/pr94234-1.c: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/94234] missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1))
2020-03-20 11:14 [Bug tree-optimization/94234] New: missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1)) fxue at os dot amperecomputing.com
` (2 preceding siblings ...)
2020-08-19 14:30 ` cvs-commit at gcc dot gnu.org
@ 2020-09-15 3:15 ` cvs-commit at gcc dot gnu.org
2020-09-15 14:55 ` cvs-commit at gcc dot gnu.org
2020-09-16 2:30 ` fxue at os dot amperecomputing.com
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-15 3:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94234
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Feng Xue <fxue@gcc.gnu.org>:
https://gcc.gnu.org/g:f9d2def016410a2095df6b399097b482f82064a5
commit r11-3199-gf9d2def016410a2095df6b399097b482f82064a5
Author: Feng Xue <fxue@os.amperecomputing.com>
Date: Tue Sep 1 17:17:58 2020 +0800
tree-optimization/94234 - Fold plusminus_mult expr with multi-use operands
2020-09-03 Feng Xue <fxue@os.amperecomputing.com>
gcc/
PR tree-optimization/94234
* genmatch.c (dt_simplify::gen_1): Emit check on final
simplification
result when "!" is specified on toplevel output expr.
* match.pd ((A * C) +- (B * C) -> (A +- B) * C): Allow folding on
expr
with multi-use operands if final result is a simple gimple value.
gcc/testsuite/
PR tree-optimization/94234
* gcc.dg/pr94234-2.c: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/94234] missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1))
2020-03-20 11:14 [Bug tree-optimization/94234] New: missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1)) fxue at os dot amperecomputing.com
` (3 preceding siblings ...)
2020-09-15 3:15 ` cvs-commit at gcc dot gnu.org
@ 2020-09-15 14:55 ` cvs-commit at gcc dot gnu.org
2020-09-16 2:30 ` fxue at os dot amperecomputing.com
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-15 14:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94234
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Feng Xue <fxue@gcc.gnu.org>:
https://gcc.gnu.org/g:8f0d743c2dee6afae5c6f861b0642b7b112a4a70
commit r11-3207-g8f0d743c2dee6afae5c6f861b0642b7b112a4a70
Author: Feng Xue <fxue@os.amperecomputing.com>
Date: Mon Aug 17 23:00:35 2020 +0800
tree-optimization/94234 - add plusminus-with-convert pattern
Add a rule (T)(A) +- (T)(B) -> (T)(A +- B), which works only when (A +- B)
could be folded to a simple value. By this rule, a
plusminus-mult-with-convert
expression could be handed over to the rule (A * C) +- (B * C) -> (A +- B).
2020-09-15 Feng Xue <fxue@os.amperecomputing.com>
gcc/
PR tree-optimization/94234
* match.pd (T)(A) +- (T)(B) -> (T)(A +- B): New simplification.
gcc/testsuite/
PR tree-optimization/94234
* gcc.dg/pr94234-3.c: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/94234] missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1))
2020-03-20 11:14 [Bug tree-optimization/94234] New: missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1)) fxue at os dot amperecomputing.com
` (4 preceding siblings ...)
2020-09-15 14:55 ` cvs-commit at gcc dot gnu.org
@ 2020-09-16 2:30 ` fxue at os dot amperecomputing.com
5 siblings, 0 replies; 7+ messages in thread
From: fxue at os dot amperecomputing.com @ 2020-09-16 2:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94234
Feng Xue <fxue at os dot amperecomputing.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #6 from Feng Xue <fxue at os dot amperecomputing.com> ---
Fixed.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-09-16 2:30 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-20 11:14 [Bug tree-optimization/94234] New: missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1)) fxue at os dot amperecomputing.com
2020-03-20 14:16 ` [Bug tree-optimization/94234] " rguenth at gcc dot gnu.org
2020-03-20 15:50 ` glisse at gcc dot gnu.org
2020-08-19 14:30 ` cvs-commit at gcc dot gnu.org
2020-09-15 3:15 ` cvs-commit at gcc dot gnu.org
2020-09-15 14:55 ` cvs-commit at gcc dot gnu.org
2020-09-16 2:30 ` fxue at os dot amperecomputing.com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).