Bug 29985

Summary: sin (x) / cos (x) is not always folded to tan (x)
Product: gcc Reporter: Uroš Bizjak <ubizjak>
Component: tree-optimizationAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: enhancement CC: gabravier, gcc-bugs, ubizjak
Priority: P3 Keywords: missed-optimization
Version: 4.3.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2006-11-26 08:01:12
Bug Depends on: 15459    
Bug Blocks:    

Description Uroš Bizjak 2006-11-26 07:44:52 UTC
This testcase shows the problem when compiled with -ffast-math:

double test1(double x)
{
        double y1, y2;

        y1 = sin(x);
        y2 = cos(x);

        return y1 / y2;
}

double test2(double x)
{
        return sin(x) / cos(x);
}

gcc -O2 -ffast-math:

_.099t.optimized:

;; Function test2 (test2)

Analyzing Edge Insertions.
test2 (x)
{
<bb 2>:
  return __builtin_tan (x) [tail call];

}



;; Function test1 (test1)

Analyzing Edge Insertions.
test1 (x)
{
<bb 2>:
  return sin (x) / cos (x);

}
Comment 1 Andrew Pinski 2006-11-26 08:01:12 UTC
This comes down to a tree combiner really.
Comment 2 Andrew Pinski 2006-11-26 08:15:02 UTC
Actually I think it is better to mark this as a dup of bug 14541 which is all about combining expressions for math builtins.

*** This bug has been marked as a duplicate of 14541 ***