<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/75592>75592</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            unexpected output results in fusion using -Os
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Elowen-jjw
      </td>
    </tr>
</table>

<pre>
    For the following two c files, I performed the equivalent transformation of loop from **file1.c** to **file2.c**. I ran these two files respectively using different optimization levels including **-O0**, **-O1**, **-O2**, **-O3**, **-Os**, **-Ofast**. The exact output results(i.e. checksum values) are:
```
                -O0 -O1             -O2             -O3             -Os             -Ofast 
file1.c        6BB53573        64EEDCA5        78F90205 78F90205        6BB53573        78F90205     
file2.c        6BB53573 64EEDCA5        78F90205        78F90205        64EEDCA5        78F90205 
```
 
Please help me to explain why these two files produced different output results when using the same optimization level(i.e. -Os), thank you.

command line:
```
clang <filename.c> <optimization level> -lm -I $CSMITH_HOME/include && ./a.out
```
version: clang+llvm 14.0.0
os: ubuntu 22.04

**file1.c**
```

#include "csmith.h"

static int32_t g_a96[4];
static uint64_t g_b96[4];

struct S0 {
  volatile uint16_t f0;
  int32_t f1;
 unsigned f2 : 24;
  int64_t f3;
};

struct S1 {
  unsigned f0 : 6;
  unsigned f1 : 5;
  signed f2 : 15;
  volatile uint8_t f3;
 signed f4 : 12;
};

static uint64_t g_35[1][2][1] = {{{0xE3C489718B2F1036LL}, {0xE3C489718B2F1036LL}}};
static struct S1 g_46[1][2][2] = {{{{6, 2, 127, 0x92L, -50}, {6, 2, 127, 0x92L, -50}}, {{6, 2, 127, 0x92L, -50}, {6, 2, 127, 0x92L, -50}}}};
static volatile struct S0 g_53 = {0x4032L, 0xAA3630DDL, 2867, 0x930CB0470BDE7D1ELL};
static struct S0 g_72 = {1UL, 0xCEF6D7B3L, 1180, 0xCAAAB22D3B6D3E8DLL};
static struct S1 *g_200 = &g_46[0][1][1];
static struct S1 **g_199[3][3][1] = {{{&g_200}, {&g_200}, {&g_200}}, {{&g_200}, {&g_200}, {&g_200}}, {{&g_200}, {&g_200}, {&g_200}}};

static void func_1(void);

static void func_1(void) {
  int32_t l_5 = 0L;
  int i;
  int ii_0;
  // fusion
  for (i = 0, ii_0 = 0; i < 3; i++, ii_0++) {
    g_a96[ii_0] = g_72.f0 * l_5 + g_53.f1;
  }
  int jj_0;
  for (jj_0 = 0; jj_0 < 4; jj_0++) {
 g_b96[jj_0] = (**g_199[2][2][0]).f0 * g_a96[jj_0] + g_35[0][0][0];
 }
}

int main(void) {
  int i, j, k;
  int print_hash_value = 0;
  platform_main_begin();
  crc32_gentab();
  func_1();
  for (i = 0; i < 1; i++) {
    for (j = 0; j < 2; j++) {
      for (k = 0; k < 1; k++) {
        transparent_crc(g_35[i][j][k], "g_35[i][j][k]", print_hash_value);
      }
    }
  }
  for (i = 0; i < 1; i++) {
    for (j = 0; j < 2; j++) {
      for (k = 0; k < 2; k++) {
 transparent_crc(g_46[i][j][k].f0, "g_46[i][j][k].f0", print_hash_value);
        transparent_crc(g_46[i][j][k].f1, "g_46[i][j][k].f1", print_hash_value);
 transparent_crc(g_46[i][j][k].f2, "g_46[i][j][k].f2", print_hash_value);
        transparent_crc(g_46[i][j][k].f3, "g_46[i][j][k].f3", print_hash_value);
 transparent_crc(g_46[i][j][k].f4, "g_46[i][j][k].f4", print_hash_value);
      }
    }
  }
  transparent_crc(g_53.f0, "g_53.f0", print_hash_value);
  transparent_crc(g_53.f1, "g_53.f1", print_hash_value);
  transparent_crc(g_53.f2, "g_53.f2", print_hash_value);
  transparent_crc(g_53.f3, "g_53.f3", print_hash_value);
  transparent_crc(g_72.f0, "g_72.f0", print_hash_value);
  transparent_crc(g_72.f1, "g_72.f1", print_hash_value);
  transparent_crc(g_72.f2, "g_72.f2", print_hash_value);
  transparent_crc(g_72.f3, "g_72.f3", print_hash_value);
  for (i = 0; i < 4; i++) {
 transparent_crc(g_a96[i], "g_a96[i]", print_hash_value);
  }
  for (i = 0; i < 4; i++) {
    transparent_crc(g_b96[i], "g_b96[i]", print_hash_value);
  }
  platform_main_end(crc32_context ^ 0xFFFFFFFFUL, print_hash_value);
  return 0;
}

```

**file2.c**
```

#include "csmith.h"

static int32_t g_a96[4];
static uint64_t g_b96[4];

struct S0 {
  volatile uint16_t f0;
  int32_t f1;
 unsigned f2 : 24;
  int64_t f3;
};

struct S1 {
  unsigned f0 : 6;
  unsigned f1 : 5;
  signed f2 : 15;
  volatile uint8_t f3;
 signed f4 : 12;
};

static uint64_t g_35[1][2][1] = {{{0xE3C489718B2F1036LL}, {0xE3C489718B2F1036LL}}};
static struct S1 g_46[1][2][2] = {{{{6, 2, 127, 0x92L, -50}, {6, 2, 127, 0x92L, -50}}, {{6, 2, 127, 0x92L, -50}, {6, 2, 127, 0x92L, -50}}}};
static volatile struct S0 g_53 = {0x4032L, 0xAA3630DDL, 2867, 0x930CB0470BDE7D1ELL};
static struct S0 g_72 = {1UL, 0xCEF6D7B3L, 1180, 0xCAAAB22D3B6D3E8DLL};
static struct S1 *g_200 = &g_46[0][1][1];
static struct S1 **g_199[3][3][1] = {{{&g_200}, {&g_200}, {&g_200}}, {{&g_200}, {&g_200}, {&g_200}}, {{&g_200}, {&g_200}, {&g_200}}};

static void func_1(void);

static void func_1(void) {
  int32_t l_5 = 0L;
  int i;
  int ii_0;
  int jj_0;
  int ij_0;
  // fusion
  for (i = 0, ii_0 = 0, jj_0 = 0, ij_0 = 0; ij_0 <= 4; ij_0++) {
    if (ij_0 <= 3 && i < 3) {
      g_a96[ii_0] = g_72.f0 * l_5 + g_53.f1;
      i++;
      ii_0++;
    }
    if (ij_0 <= 4 && jj_0 < 4) {
      g_b96[jj_0] = (**g_199[2][2][0]).f0 * g_a96[jj_0] + g_35[0][0][0];
      jj_0++;
    }
  }
}

int main(void) {
  int i, j, k;
  int print_hash_value = 0;
 platform_main_begin();
  crc32_gentab();
  func_1();
  for (i = 0; i < 1; i++) {
    for (j = 0; j < 2; j++) {
      for (k = 0; k < 1; k++) {
        transparent_crc(g_35[i][j][k], "g_35[i][j][k]", print_hash_value);
      }
    }
  }
  for (i = 0; i < 1; i++) {
    for (j = 0; j < 2; j++) {
      for (k = 0; k < 2; k++) {
 transparent_crc(g_46[i][j][k].f0, "g_46[i][j][k].f0", print_hash_value);
        transparent_crc(g_46[i][j][k].f1, "g_46[i][j][k].f1", print_hash_value);
 transparent_crc(g_46[i][j][k].f2, "g_46[i][j][k].f2", print_hash_value);
        transparent_crc(g_46[i][j][k].f3, "g_46[i][j][k].f3", print_hash_value);
 transparent_crc(g_46[i][j][k].f4, "g_46[i][j][k].f4", print_hash_value);
      }
    }
  }
  transparent_crc(g_53.f0, "g_53.f0", print_hash_value);
  transparent_crc(g_53.f1, "g_53.f1", print_hash_value);
  transparent_crc(g_53.f2, "g_53.f2", print_hash_value);
  transparent_crc(g_53.f3, "g_53.f3", print_hash_value);
  transparent_crc(g_72.f0, "g_72.f0", print_hash_value);
  transparent_crc(g_72.f1, "g_72.f1", print_hash_value);
  transparent_crc(g_72.f2, "g_72.f2", print_hash_value);
  transparent_crc(g_72.f3, "g_72.f3", print_hash_value);
  for (i = 0; i < 4; i++) {
 transparent_crc(g_a96[i], "g_a96[i]", print_hash_value);
  }
  for (i = 0; i < 4; i++) {
    transparent_crc(g_b96[i], "g_b96[i]", print_hash_value);
  }
  platform_main_end(crc32_context ^ 0xFFFFFFFFUL, print_hash_value);
  return 0;
}

```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWt-PukgS_2val4qkqQbUBx_EH9lvMpu5ZPeeTQuNtoPgQeM499dfugEBlRlv9nu3u4nGCFVd9anqqqK7qcjzXG4TIabE9Ym7GPBC7dJsuozTd5EM9_v3wSYNP6arNAO1ExClcZy-y2QL6j2FACIZi5zgHH7AUWRRmh1EaATFvwp54rFIFKiMJ7ke4kqmCaQRxGl6h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