Skip to content

[X86][GISel] Wrong code at -O0 #168877

@XChy

Description

@XChy

Testcase:

#include "stdio.h"
#include "stdint.h"
#include "limits.h"

int32_t g_21[5][2];
int32_t g_2121[];

int32_t func_14(int32_t, int64_t, int32_t, int32_t *, int8_t);
int32_t func_1() {
  int32_t *l_20 = &g_21[4][1];
  uint64_t l_2506 = 4;
  *l_20 = func_14(0, 0, 2, &g_2121[0], l_2506) - 1;
  return 0;
}
int32_t func_14(int32_t, int64_t, int32_t, int32_t *p_18, int8_t) {
  return *p_18;
}
int main() {
  func_1();
  printf("checksum = %08X\n", g_21[4][1]);
}

Reproducer command: clang -fglobal-isel -O0 testcase.c
output: checksum = 0041995F (the output is indeterministic)

When compiling with GCC or Clang with other optimization flags, the output is checksum = FFFFFFFF

Somehow, I cannot reproduce it on Godbolt. However, I can reproduce at trunk commit 76f1949 and clang-17, and on both processors Intel(R) Xeon(R) Gold 5118 CPU @ 2.30GHz and 12th Gen Intel(R) Core(TM) i7-12700H.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions