http://llvm.org/bugs/show_bug.cgi?id=20205
Bug ID: 20205
Summary: Performance problem with an integer division benchmark
Product: clang
Version: 3.4
Hardware: PC
OS: Windows XP
Status: NEW
Keywords: code-quality
Severity: normal
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
While running a little benchmark on the LDC compiler (version 0.13.0 based on
DMD v2.064 and LLVM 3.4.2), I have found it being significantly (like five
times) slower than equivalent C code compiled with GCC 4.8.0 (using -O3
-std=c99, do not use -O2) on a 32 bit Windows system. Later others in the D
newsgroup (http://forum.dlang.org/thread/[email protected] )
have confirmed it's not a LDC problem, but a back-end problem.
The title of this issue is generic because I don't know the exact causes. Feel
free to rename it.
The C code:
#include <stdio.h>
#include <stdbool.h>
const int t = 20;
bool isEvenlyDivisible(const int i, const int a, const int b) {
if (i > b)
return true;
else
return (a % i == 0) && isEvenlyDivisible(i + 1, a, b);
}
void run() {
int i = 10;
while (!isEvenlyDivisible(2, i, t))
i += 2;
printf("%d\n", i);
}
int main() {
for (int i = 0; i < 5; i++)
run();
return 0;
}
------------------
The C-style D version:
import core.stdc.stdio;
enum int t = 20;
bool isEvenlyDivisible(in int i, in int a, in int b)
pure nothrow @safe {
if (i > b)
return true;
else
return (a % i == 0) && isEvenlyDivisible(i + 1, a, b);
}
void run() nothrow {
int i = 10;
while (!isEvenlyDivisible(2, i, t))
i += 2;
printf("%d\n", i);
}
void main() {
for (int i = 0; i < 5; i++)
run;
}
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs