public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/96429] New: d: Pointer subtraction uses TRUNC_DIV_EXPR
@ 2020-08-03 11:13 ibuclaw at gdcproject dot org
2020-08-03 12:21 ` [Bug d/96429] " ibuclaw at gdcproject dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: ibuclaw at gdcproject dot org @ 2020-08-03 11:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96429
Bug ID: 96429
Summary: d: Pointer subtraction uses TRUNC_DIV_EXPR
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: d
Assignee: ibuclaw at gdcproject dot org
Reporter: ibuclaw at gdcproject dot org
Target Milestone: ---
Given the pointer operation:
long delta = smaller & (read - first);
This gets lowered as (-fdump-tree-original)
long delta = (long) smaller & (read - first) / 8;
Instead of...
long delta = (long) smaller & (read - first) /[ex] 8;
Switching will likely give some marginal gains on performance.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug d/96429] d: Pointer subtraction uses TRUNC_DIV_EXPR
2020-08-03 11:13 [Bug d/96429] New: d: Pointer subtraction uses TRUNC_DIV_EXPR ibuclaw at gdcproject dot org
@ 2020-08-03 12:21 ` ibuclaw at gdcproject dot org
2020-08-04 8:26 ` cvs-commit at gcc dot gnu.org
2020-08-04 8:27 ` ibuclaw at gdcproject dot org
2 siblings, 0 replies; 4+ messages in thread
From: ibuclaw at gdcproject dot org @ 2020-08-03 12:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96429
--- Comment #1 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
--- a/gcc/d/expr.cc
+++ b/gcc/d/expr.cc
@@ -620,6 +620,18 @@ public:
break;
case TOKdiv:
+ /* Determine if the div expression is a lowered pointer diff operation.
+ The front-end rewrites `(p1 - p2)' into `(p1 - p2) / stride'. */
+ if (MinExp *me = e->e1->isMinExp ())
+ {
+ if (me->e1->type->ty == Tpointer && me->e2->type->ty == Tpointer
+ && e->e2->op == TOKint64)
+ {
+ code = EXACT_DIV_EXPR;
+ break;
+ }
+ }
+
code = e->e1->type->isintegral ()
? TRUNC_DIV_EXPR : RDIV_EXPR;
break;
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug d/96429] d: Pointer subtraction uses TRUNC_DIV_EXPR
2020-08-03 11:13 [Bug d/96429] New: d: Pointer subtraction uses TRUNC_DIV_EXPR ibuclaw at gdcproject dot org
2020-08-03 12:21 ` [Bug d/96429] " ibuclaw at gdcproject dot org
@ 2020-08-04 8:26 ` cvs-commit at gcc dot gnu.org
2020-08-04 8:27 ` ibuclaw at gdcproject dot org
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-04 8:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96429
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:
https://gcc.gnu.org/g:3a3fda119036f46bfa70e06e7c69e04e78040079
commit r11-2536-g3a3fda119036f46bfa70e06e7c69e04e78040079
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Mon Aug 3 22:35:38 2020 +0200
d: Fix PR96429: Pointer subtraction uses TRUNC_DIV_EXPR
gcc/d/ChangeLog:
PR d/96429
* expr.cc (ExprVisitor::visit (BinExp*)): Use EXACT_DIV_EXPR for
pointer diff expressions.
gcc/testsuite/ChangeLog:
PR d/96429
* gdc.dg/pr96429.d: New test.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug d/96429] d: Pointer subtraction uses TRUNC_DIV_EXPR
2020-08-03 11:13 [Bug d/96429] New: d: Pointer subtraction uses TRUNC_DIV_EXPR ibuclaw at gdcproject dot org
2020-08-03 12:21 ` [Bug d/96429] " ibuclaw at gdcproject dot org
2020-08-04 8:26 ` cvs-commit at gcc dot gnu.org
@ 2020-08-04 8:27 ` ibuclaw at gdcproject dot org
2 siblings, 0 replies; 4+ messages in thread
From: ibuclaw at gdcproject dot org @ 2020-08-04 8:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96429
Iain Buclaw <ibuclaw at gdcproject dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|UNCONFIRMED |RESOLVED
--- Comment #3 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
Fixed.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-04 8:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-03 11:13 [Bug d/96429] New: d: Pointer subtraction uses TRUNC_DIV_EXPR ibuclaw at gdcproject dot org
2020-08-03 12:21 ` [Bug d/96429] " ibuclaw at gdcproject dot org
2020-08-04 8:26 ` cvs-commit at gcc dot gnu.org
2020-08-04 8:27 ` ibuclaw at gdcproject dot org
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).