This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug optimization/14673] [tree-ssa] DOM misses ABS to negative translation


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]