This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/14673] [tree-ssa] DOM misses ABS to negative translation
- From: "law at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 May 2004 19:45:14 -0000
- Subject: [Bug optimization/14673] [tree-ssa] DOM misses ABS to negative translation
- References: <20040321225046.14673.pinskia@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From law at redhat dot com 2004-05-04 19:45 -------
Subject: Re: New: [tree-ssa] DOM misses ABS to
negative translation
In message <20040321225046.14673.pinskia@gcc.gnu.org>, "pinskia at gcc dot gnu
dot org" writes:
>/* { dg-do compile } */
>/* { dg-options "-O1 -fdump-tree-dom3" } */
>int
>foo2 (distance, i, j)
> int distance;
> int i, j;
>{
> int t = distance;
> if (t <= 0)
> t = ((t) >= 0 ? (t) : -(t));
> return t;
>}
>
>/* There should be no ABS_EXPR. */
>/* { dg-final { scan-tree-dump-times "ABS_EXPR " 0 "dom3"} } */
>
>Noticed while looking to why a test fail (gcc.dg/tree-ssa/20030807-6.c) on
> the lno branch after applying my patch to find ABS in phiopt.
Sigh.
Given x LT 0 == true we would transform ABS into negation
x GE 0 == true we would eliminate ABS completely
[ These were performed with a single test of the available expression table. ]
That's not precisely what we want since if we had recorded x LE 0 == true
neither test would trigger, but we want to transform ABS into negation.
The right way to handle this is to do something like
x LE 0 == true turn abs into negation
x GE 0 == true eliminate abs completely
Which requires two checks of the available expression table. Easy 'nuff.
I'll check in a fix for this once the merge is complete.
Jeff
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14673