public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/22568] New: Should use cmov in some stituations @ 2005-07-20 14:21 arndt at jjj dot de 2005-07-20 14:27 ` [Bug c++/22568] " matz at suse dot de ` (5 more replies) 0 siblings, 6 replies; 12+ messages in thread From: arndt at jjj dot de @ 2005-07-20 14:21 UTC (permalink / raw) To: gcc-bugs With (ulong a, ulong b) and code like if ( a<b ) { ulong t=a; a=b; b=t; } gcc should (if a and b are in registers already) not emit a conditional jump but code like MOV a, t; CMP a, b; CMOVcc b, a; CMOVcc t, b; Other such examples are easily found. If I got it correctly, gcc emits CMOVcc in just one situation, the conditional assignment. Machine is AMD64, OS is SuSE Linux 9.3 gcc (GCC) 3.3.5 20050117 (prerelease) (SUSE Linux) -- Summary: Should use cmov in some stituations Product: gcc Version: unknown Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: arndt at jjj dot de CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22568 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [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; 12+ 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] 12+ 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; 12+ 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] 12+ 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; 12+ 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] 12+ 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; 12+ 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] 12+ 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; 12+ 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] 12+ 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; 12+ 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] 12+ messages in thread
[parent not found: <bug-22568-11024@http.gcc.gnu.org/bugzilla/>]
* [Bug rtl-optimization/22568] Should use cmov in some stituations [not found] <bug-22568-11024@http.gcc.gnu.org/bugzilla/> @ 2006-01-15 3:14 ` pinskia at gcc dot gnu dot org 2006-01-15 4:05 ` pinskia at gcc dot gnu dot org 2006-01-15 19:11 ` rguenth at gcc dot gnu dot org 2 siblings, 0 replies; 12+ messages in thread From: pinskia at gcc dot gnu dot org @ 2006-01-15 3:14 UTC (permalink / raw) To: gcc-bugs ------- Comment #9 from pinskia at gcc dot gnu dot org 2006-01-15 03:14 ------- This might be fixed by (I am checking right now): 2006-01-14 Ian Lance Taylor <ian@airs.com> * ifcvt.c (noce_init_if_info): New static function, broken out of noce_process_if_block. (noce_process_if_block): Call noce_init_if_info. (check_cond_move_block): New static function. (cond_move_process_if_block): New static function. (process_if_block): Call cond_move_process_if_block. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22568 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/22568] Should use cmov in some stituations [not found] <bug-22568-11024@http.gcc.gnu.org/bugzilla/> 2006-01-15 3:14 ` pinskia at gcc dot gnu dot org @ 2006-01-15 4:05 ` pinskia at gcc dot gnu dot org 2006-01-15 19:11 ` rguenth at gcc dot gnu dot org 2 siblings, 0 replies; 12+ messages in thread From: pinskia at gcc dot gnu dot org @ 2006-01-15 4:05 UTC (permalink / raw) To: gcc-bugs ------- Comment #10 from pinskia at gcc dot gnu dot org 2006-01-15 04:05 ------- This was not fixed. If I rewrite the function like: ulong f1(ulong a, ulong b) { ulong tmp = a<b?b:a; ulong tmp1 = a<b?a:b; a = tmp; b = tmp1; return use (a, b)+use(a,b); } It works. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22568 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/22568] Should use cmov in some stituations [not found] <bug-22568-11024@http.gcc.gnu.org/bugzilla/> 2006-01-15 3:14 ` pinskia at gcc dot gnu dot org 2006-01-15 4:05 ` pinskia at gcc dot gnu dot org @ 2006-01-15 19:11 ` rguenth at gcc dot gnu dot org 2 siblings, 0 replies; 12+ messages in thread From: rguenth at gcc dot gnu dot org @ 2006-01-15 19:11 UTC (permalink / raw) To: gcc-bugs ------- Comment #11 from rguenth at gcc dot gnu dot org 2006-01-15 19:11 ------- Created an attachment (id=10647) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10647&action=view) patch aft the point I stopped working on this -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22568 ^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <bug-22568-4@http.gcc.gnu.org/bugzilla/>]
* [Bug rtl-optimization/22568] Should use cmov in some stituations [not found] <bug-22568-4@http.gcc.gnu.org/bugzilla/> @ 2012-02-08 21:01 ` pinskia at gcc dot gnu.org 2021-05-24 6:13 ` pinskia at gcc dot gnu.org 1 sibling, 0 replies; 12+ messages in thread From: pinskia at gcc dot gnu.org @ 2012-02-08 21:01 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22568 --- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-02-08 20:59:51 UTC --- I have a patch to tree-ssa-phiopt.c to fix comment #1 though it needs another patch to expr.c to produce the cmov directly from COND_EXPR. I hope to post both patches for 4.8.0. ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/22568] Should use cmov in some stituations [not found] <bug-22568-4@http.gcc.gnu.org/bugzilla/> 2012-02-08 21:01 ` pinskia at gcc dot gnu.org @ 2021-05-24 6:13 ` pinskia at gcc dot gnu.org 1 sibling, 0 replies; 12+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-05-24 6:13 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=22568 --- Comment #16 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #15) > The expr.c patch yes. The tree-ssa-phiopt.c patch, no. Tree-ssa-phiopt.c > needs more code rework because of the new infrastructures so I have not > gotten around to improving the patch yet; been busy with other stuff. The patch for PR 25290 includes the most of the infrastructure to implement cmov at the gimple level (See match_simplify_replacement and late_p argument) but is not enabled because I think it might require a cost model. ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2021-05-24 6:13 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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 2005-09-02 9:47 ` bonzini at gcc dot gnu dot org 2005-09-02 9:54 ` rguenth at gcc dot gnu dot org [not found] <bug-22568-11024@http.gcc.gnu.org/bugzilla/> 2006-01-15 3:14 ` pinskia at gcc dot gnu dot org 2006-01-15 4:05 ` pinskia at gcc dot gnu dot org 2006-01-15 19:11 ` rguenth at gcc dot gnu dot org [not found] <bug-22568-4@http.gcc.gnu.org/bugzilla/> 2012-02-08 21:01 ` pinskia at gcc dot gnu.org 2021-05-24 6:13 ` pinskia at gcc dot gnu.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).