[Bug middle-end/37780] Conditional expression with __builtin_clz() should be optimized out

2012-03-20 Thread amker.cheng at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37780

--- Comment #2 from amker.cheng  2012-03-20 
07:58:09 UTC ---
the special case could be easily detected when gimplifying.
but actually I am not sure whether it can be done even in middle end, since the
middle end should not depend on any target information, like
CLZ_DEFINED_VALUE_AT_ZERO, right?


[Bug middle-end/37780] Conditional expression with __builtin_clz() should be optimized out

2016-06-06 Thread ktkachov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37780

--- Comment #4 from ktkachov at gcc dot gnu.org ---
Author: ktkachov
Date: Mon Jun  6 15:59:48 2016
New Revision: 237138

URL: https://gcc.gnu.org/viewcvs?rev=237138&root=gcc&view=rev
Log:
[1/3][ARM] Keep ctz expressions together until after reload

PR middle-end/37780
* config/arm/arm.md (ctzsi2): Convert to define_insn_and_split.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/arm/arm.md

[Bug middle-end/37780] Conditional expression with __builtin_clz() should be optimized out

2016-06-06 Thread ktkachov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37780

--- Comment #5 from ktkachov at gcc dot gnu.org ---
Author: ktkachov
Date: Mon Jun  6 16:01:47 2016
New Revision: 237139

URL: https://gcc.gnu.org/viewcvs?rev=237139&root=gcc&view=rev
Log:
[2/3][AArch64] Keep CTZ components together until after reload

PR middle-end/37780
* config/aarch64/aarch64.md (ctz2): Convert to
define_insn_and_split.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/aarch64/aarch64.md

[Bug middle-end/37780] Conditional expression with __builtin_clz() should be optimized out

2016-06-06 Thread ktkachov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37780

--- Comment #6 from ktkachov at gcc dot gnu.org ---
Author: ktkachov
Date: Mon Jun  6 16:06:05 2016
New Revision: 237141

URL: https://gcc.gnu.org/viewcvs?rev=237141&root=gcc&view=rev
Log:
[3/3][RTL ifcvt] PR middle-end/37780: Conditional expression with
__builtin_clz() should be optimized out

PR middle-end/37780
* ifcvt.c (noce_try_ifelse_collapse): New function.
Declare prototype.
(noce_process_if_block): Call noce_try_ifelse_collapse.
* simplify-rtx.c (simplify_cond_clz_ctz): New function.
(simplify_ternary_operation): Use the above to simplify
conditional CLZ/CTZ expressions.

* gcc.c-torture/execute/pr37780.c: New test.
* gcc.target/aarch64/pr37780_1.c: Likewise.
* gcc.target/arm/pr37780_1.c: Likewise.

Added:
trunk/gcc/testsuite/gcc.c-torture/execute/pr37780.c
trunk/gcc/testsuite/gcc.target/aarch64/pr37780_1.c
trunk/gcc/testsuite/gcc.target/arm/pr37780_1.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/ifcvt.c
trunk/gcc/simplify-rtx.c
trunk/gcc/testsuite/ChangeLog

[Bug middle-end/37780] Conditional expression with __builtin_clz() should be optimized out

2016-06-15 Thread ktkachov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37780

ktkachov at gcc dot gnu.org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #7 from ktkachov at gcc dot gnu.org ---
Fixed for GCC 7

[Bug middle-end/37780] Conditional expression with __builtin_clz() should be optimized out

2016-04-29 Thread ktkachov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37780

ktkachov at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||ktkachov at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |ktkachov at gcc dot 
gnu.org

--- Comment #3 from ktkachov at gcc dot gnu.org ---
I'll have a look

[Bug middle-end/37780] Conditional expression with __builtin_clz() should be optimized out

2009-03-28 Thread fxcoudert at gcc dot gnu dot org


--- Comment #1 from fxcoudert at gcc dot gnu dot org  2009-03-28 16:33 
---
This is not a Fortran issue, it should be done in the middle-end. On platforms
that have a defined value for __builtin_clz(0), the conditional in the function
below should be optimized out:

int foo (int i)
{
  return (i == 0) ? sizeof (int) * 8 : __builtin_clz (i);
}

Targets where this is expected to be an issue are: alpha, cris, rs6000, m68k,
arm and s390.


-- 

fxcoudert at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
  Component|fortran |middle-end
 Ever Confirmed|0   |1
 GCC target triplet||CLZ_DEFINED_VALUE_AT_ZERO !=
   ||0
   Last reconfirmed|-00-00 00:00:00 |2009-03-28 16:33:36
   date||
Summary|Optimize LEADZ/TRAILZ for   |Conditional expression with
   |zero arguments  |__builtin_clz() should be
   ||optimized out


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37780