blob: bf69201d9a575a6a583e88ac7283ab288f3bd9b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110359
// { dg-do compile }
// { dg-options "-fdump-tree-original" }
double pow(in double x, in ulong p)
{
import gcc.builtins : __builtin_expect;
if (__builtin_expect(p == 0, false))
return 1;
if (__builtin_expect(p == 1, false))
return x;
double s = x;
double v = 1;
for (ulong i = p; i > 1; i >>= 1)
{
v = (i & 0x1) ? s * v : v;
s = s * s;
}
return v * s;
}
// { dg-final { scan-tree-dump "if \\(__builtin_expect \\(p == 0, 0\\) != 0\\)" "original" } }
// { dg-final { scan-tree-dump "if \\(__builtin_expect \\(p == 1, 0\\) != 0\\)" "original" } }
|