public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "luoxhu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/22326] promotions (from float to double) are not removed when they should be able to
Date: Mon, 30 Nov 2020 08:31:34 +0000 [thread overview]
Message-ID: <bug-22326-4-pMAUZDGwWL@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-22326-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=22326
--- Comment #17 from luoxhu at gcc dot gnu.org ---
(In reply to rsandifo@gcc.gnu.org from comment #16)
> > 2) mad2.c
> >
> > float foo (double x, float y, float z)
> > {
> > return ( y * fabs (x) + z );
> > }
> >
> >
> > mad2.c.098t.cunrolli:
> >
> > foo (double x, float y, float z)
> > {
> > double _1;
> > double _2;
> > double _3;
> > double _4;
> > double _5;
> > float _9;
> >
> > <bb 2> [local count: 1073741824]:
> > _1 = (double) y_6(D);
> > _2 = ABS_EXPR <x_7(D)>;
> > _3 = _1 * _2;
> > _4 = (double) z_8(D);
> > _5 = _3 + _4;
> > _9 = (float) _5;
> > return _9;
> >
> > }
> >
> > mad2.c.099t.backprop:
> >
> > [USE] _9 in return _9;
> > [USE] _5 in _9 = (float) _5;
> > _5: convert from float to double not important
> > [DEF] Recording new information for _5 = _3 + _4;
> > _5: convert from float to double not important
> > [USE] _4 in _5 = _3 + _4;
> > _4: convert from float to double not important
> > [DEF] Recording new information for _4 = (double) z_8(D);
> > _4: convert from float to double not important
> > [USE] _3 in _5 = _3 + _4;
> > _3: convert from float to double not important
> > [DEF] Recording new information for _3 = _1 * _2;
> > _3: convert from float to double not important
> > [USE] _2 in _3 = _1 * _2;
> > _2: convert from float to double not important
> > [DEF] Recording new information for _2 = ABS_EXPR <x_7(D)>;
> > _2: convert from float to double not important
> > [USE] _1 in _3 = _1 * _2;
> > _1: convert from float to double not important
> > [DEF] Recording new information for _1 = (double) y_6(D);
> > _1: convert from float to double not important
> >
> > Deleting _4 = (double) z_8(D);
> > Deleting _1 = (double) y_6(D);
> >
> >
> > EMERGENCY DUMP:
> >
> > __attribute__((noinline))
> > foo (double x, float y, float z)
> > {
> > double _2;
> > double _3;
> > double _5;
> > float _9;
> >
> > <bb 2> [local count: 1073741824]:
> > _2 = ABS_EXPR <x_7(D)>;
> > _3 = _2 * y_6(D);
> > _5 = _3 + z_8(D);
> > _9 = (float) _5;
> > return _9;
> >
> > }
> Maybe I'm misunderstanding the point, but isn't this
> just an issue with the way that the results of the
> analysis are applied to the IL, rather than a problem
> in the analysis itself?
Yes, the optimize operations on Gimple is a bit uncertain.
Do you mean add convert from double to float at proper place
like below to avoid ICE caused by type mismatch ICE in verify_ssa?
Which one will be better, and whether it is correct for all kind
of math operations like pow/exp, etc under fast-math? If so, no
cancelling is needed again as Richi mentioned?
1) convert before ABS_EXPR:
foo (double x, float y, float z)
{
float _9;
float _11;
float _12;
float _13;
float _14;
<bb 2> [local count: 1073741824]:
_11 = (float) x_6(D);
_12 = ABS_EXPR <_11>;
_13 = y_7(D) * _12;
_14 = z_8(D) + _13;
_9 = _14;
return _9;
}
foo:
.LFB0:
.cfi_startproc
frsp 0,1
fabs 0,0
fmadds 1,2,0,3
blr
2) OR convert after ABS_EXPR:
foo (double x, float y, float z)
{
double _1;
float _9;
float _11;
float _12;
float _13;
<bb 2> [local count: 1073741824]:
_1 = ABS_EXPR <x_6(D)>;
_11 = (float) _1;
_12 = y_7(D) * _11;
_13 = z_8(D) + _12;
_9 = _13;
return _9;
}
foo:
.LFB0:
.cfi_startproc
fabs 0,1
frsp 0,0
fmadds 1,2,0,3
blr
next prev parent reply other threads:[~2020-11-30 8:31 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <bug-22326-4@http.gcc.gnu.org/bugzilla/>
2020-11-17 7:07 ` luoxhu at gcc dot gnu.org
2020-11-17 7:10 ` luoxhu at gcc dot gnu.org
2020-11-17 10:21 ` pinskia at gcc dot gnu.org
2020-11-17 21:56 ` joseph at codesourcery dot com
2020-11-18 15:22 ` segher at gcc dot gnu.org
2020-11-23 8:39 ` luoxhu at gcc dot gnu.org
2020-11-23 8:44 ` luoxhu at gcc dot gnu.org
2020-11-23 12:09 ` rguenther at suse dot de
2020-11-24 10:00 ` rsandifo at gcc dot gnu.org
2020-11-27 6:20 ` luoxhu at gcc dot gnu.org
2020-11-27 6:27 ` luoxhu at gcc dot gnu.org
2020-11-27 7:12 ` rguenther at suse dot de
2020-11-27 9:24 ` rsandifo at gcc dot gnu.org
2020-11-30 8:31 ` luoxhu at gcc dot gnu.org [this message]
2020-12-11 13:49 ` segher at gcc dot gnu.org
2020-12-11 14:24 ` rguenth at gcc dot gnu.org
2020-12-11 17:51 ` segher at gcc dot gnu.org
2020-12-11 19:24 ` rguenther at suse dot de
2020-12-14 7:21 ` luoxhu at gcc dot gnu.org
[not found] <bug-22326-6528@http.gcc.gnu.org/bugzilla/>
2006-08-21 6:08 ` pinskia at gcc dot gnu dot org
2007-07-09 6:08 ` pinskia at gcc dot gnu dot org
2005-07-06 15:40 [Bug tree-optimization/22326] New: " pinskia at gcc dot gnu dot org
2005-07-12 20:37 ` [Bug tree-optimization/22326] " pinskia at gcc dot gnu dot org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-22326-4-pMAUZDGwWL@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).