llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Wrong code at -O1 and above on x86_64-linux_gnu(recent regression)

Open shao-hua-li opened this issue 2 years ago • 2 comments

Clang at -O1 and above produces the wrong code.

Bisected to 8773c9be3d9868288f1f46957945d50ff58e4e91, which was committed by @mgudim

Compiler explorer: https://godbolt.org/z/aTKK3Prqs

% cat reduced.c
int printf(const char *, ...);
int a, b = 7, c;
int *d = &c;
int e() { return 1 & b; }
int main() {
  char f = -1;
  *d = a + f == e() + f + f;
  printf("%d\n", c);
}
%
% clang -O0 reduced.c && ./a.out
1
% clang -O1 reduced.c && ./a.out
0
%

shao-hua-li avatar Dec 21 '23 15:12 shao-hua-li

I will look into this. The offending commit was reverted: https://github.com/llvm/llvm-project/pull/76167

mgudim avatar Dec 21 '23 16:12 mgudim

This was fixed in https://github.com/llvm/llvm-project/pull/76531

mgudim avatar Jan 03 '24 08:01 mgudim