-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Labels
llvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmiscompilationregression
Description
clang at -O1/2/3 miscompiled the test.
Bisected to a66051c, which was committed by @aemerson
Compiler explorer: https://godbolt.org/z/8sMj8G9z9
% cat a.c
int printf(const char *, ...);
int a, d, e = 35435;
char b;
long c;
unsigned j;
short k, l;
int m(int n) {
char f[] = {0, 9};
char *g = f, *i = g;
long h = n;
do
*i++ = h /= 10;
while (h);
c = i - g;
while (g < i)
b = *g++;
a = c;
return c;
}
void o(int n) {
k = e;
l = (j = k) > n;
if (l)
d = 3;
}
void p() {
int q = m(17);
o(q + 65533);
}
int main() {
p();
printf("%d\n", d);
}
%
% clang -O0 a.c && ./a.out
3
% clang -O1 a.c && ./a.out
0
%Metadata
Metadata
Assignees
Labels
llvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmiscompilationregression