* [Bug c++/22568] Should use cmov in some stituations
2005-07-20 14:21 [Bug c++/22568] New: Should use cmov in some stituations arndt at jjj dot de
@ 2005-07-20 14:27 ` matz at suse dot de
2005-07-20 15:14 ` [Bug rtl-optimization/22568] " pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: matz at suse dot de @ 2005-07-20 14:27 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From matz at suse dot de 2005-07-20 14:20 -------
This still happens with 4.1. I also can't make it use two cmovs, by changing
the source a bit, e.g. like:
typedef unsigned long ulong;
extern ulong use (ulong, ulong);
ulong f(ulong a, ulong b)
{
ulong tmp = a;
if (a < b) {
a = b;
b = tmp;
}
return use (a, b);
}
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |matz at suse dot de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22568
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug rtl-optimization/22568] Should use cmov in some stituations
2005-07-20 14:21 [Bug c++/22568] New: Should use cmov in some stituations arndt at jjj dot de
2005-07-20 14:27 ` [Bug c++/22568] " matz at suse dot de
@ 2005-07-20 15:14 ` pinskia at gcc dot gnu dot org
2005-08-31 9:42 ` rguenth at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-20 15:14 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-07-20 15:11 -------
IIRC ifcvt is not smart enough to do this.
Confirmed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Component|c++ |rtl-optimization
Ever Confirmed| |1
Keywords| |missed-optimization
Last reconfirmed|0000-00-00 00:00:00 |2005-07-20 15:11:41
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22568
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug rtl-optimization/22568] Should use cmov in some stituations
2005-07-20 14:21 [Bug c++/22568] New: Should use cmov in some stituations arndt at jjj dot de
2005-07-20 14:27 ` [Bug c++/22568] " matz at suse dot de
2005-07-20 15:14 ` [Bug rtl-optimization/22568] " pinskia at gcc dot gnu dot org
@ 2005-08-31 9:42 ` rguenth at gcc dot gnu dot org
2005-09-01 12:38 ` rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-08-31 9:42 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rguenth at gcc dot gnu dot org 2005-08-31 09:40 -------
With new tree-codes instead of using COND_EXPR we may use the tree-vectorizers
if-conversion and make expand preserve the conditional moves.
Also it shouldn't be too hard to hack rtl if-conversion to handle the case of
exactly two set's in the then/else block, too, and that may turn out to be
profitable always. Is there any arch whose conditional move will kill
condition codes? RTL is not my best friend (yet), but ifcvt doens't look too bad
either ;)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22568
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug rtl-optimization/22568] Should use cmov in some stituations
2005-07-20 14:21 [Bug c++/22568] New: Should use cmov in some stituations arndt at jjj dot de
` (2 preceding siblings ...)
2005-08-31 9:42 ` rguenth at gcc dot gnu dot org
@ 2005-09-01 12:38 ` rguenth at gcc dot gnu dot org
2005-09-02 9:47 ` bonzini at gcc dot gnu dot org
2005-09-02 9:54 ` rguenth at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-09-01 12:38 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rguenth at gcc dot gnu dot org 2005-09-01 12:38 -------
I have a patch that for
int a,b;
void foo(void)
{
int x;
if (a<b) x=a,a=b,b=x;
}
produces
bar:
movl a, %eax
movl b, %edx
cmpl %edx, %eax
movl %eax, %ecx
cmovl %edx, %ecx
cmovge b, %eax
movl %ecx, a
movl %eax, b
ret
but it produces horrible code if the stuff is not available in pseudos
already. (i.e. we miss load/store sinking)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22568
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug rtl-optimization/22568] Should use cmov in some stituations
2005-07-20 14:21 [Bug c++/22568] New: Should use cmov in some stituations arndt at jjj dot de
` (3 preceding siblings ...)
2005-09-01 12:38 ` rguenth at gcc dot gnu dot org
@ 2005-09-02 9:47 ` bonzini at gcc dot gnu dot org
2005-09-02 9:54 ` rguenth at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: bonzini at gcc dot gnu dot org @ 2005-09-02 9:47 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bonzini at gcc dot gnu dot org 2005-09-02 09:47 -------
Richard, can you write a case where it produces awful code?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22568
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug rtl-optimization/22568] Should use cmov in some stituations
2005-07-20 14:21 [Bug c++/22568] New: Should use cmov in some stituations arndt at jjj dot de
` (4 preceding siblings ...)
2005-09-02 9:47 ` bonzini at gcc dot gnu dot org
@ 2005-09-02 9:54 ` rguenth at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-09-02 9:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rguenth at gcc dot gnu dot org 2005-09-02 09:54 -------
Blindly applying ifcvt to something like
int a,b;
void foo(int flag)
{
int x;
if (flag)
x=a,a=b,b=x;
}
because we're presented with
if (flag)
{
int reg_a = a;
x = reg_a;
int reg_b = b;
a = reg_b;
b = x;
}
and we get cmovs for loading a,b into pseudos instead of
loading them unconditionally. F.i.
int a,b;
void foobar(int flag)
{
if (flag)
a = b;
}
will become
foobar:
movl 4(%esp), %eax # flag, flag
testl %eax, %eax # flag
cmovne b, %edx # b,, b
movl a, %eax # a, tmp61
cmovne %edx, %eax # b,, tmp61
movl %eax, a # tmp61, a
ret
notice how we special-cased the _store_ to use a temporary. I'll
try applying the same for loads.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22568
^ permalink raw reply [flat|nested] 7+ messages in thread