<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/75607>75607</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      6F9F6359        77D95726        77D95726        77D95726 6F9F6359        77D95726     
file2.c      6F9F6359        77D95726 77D95726        77D95726        77D95726        77D95726     
```
 
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_a30[6];
static int64_t g_b30[6];

struct S0 {
  const volatile uint32_t f0;
  uint64_t f1;
  int64_t f2;
};

union U1 {
  int16_t f0;
  uint16_t f1;
  uint16_t f2;
  const struct S0 f3;
};

static volatile int32_t g_7 = 0x6B471DFDL;
static int32_t g_10 = 1L;
static int32_t g_33[2][3][1] = {{{(-7L)}, {(-7L)}, {(-7L)}}, {{(-7L)}, {(-7L)}, {(-7L)}}};
static volatile union U1 g_320 = {1L};
static volatile union U1 *g_319 = &g_320;
static volatile union U1 *volatile *const g_318 = &g_319;
static struct S0 g_350 = {2UL, 18446744073709551615UL, 0x484C2F172B251D2FLL};

static const void func_1(void);

static const void func_1(void) {
  int i;
  int ii_0;
  // fusion
  for (i = 0, ii_0 = 0; i < 3; i++, ii_0++) {
    g_a30[ii_0] = g_7 * g_10 + (**g_318).f1;
  }
  int jj_0;
  for (jj_0 = 0; jj_0 < 6; jj_0++) {
    g_b30[jj_0] = g_33[1][1][0] * g_a30[jj_0] + g_350.f2;
 }
}

int main(void) {
  int i, j, k;
  int print_hash_value = 0;
  platform_main_begin();
  crc32_gentab();
  func_1();
 transparent_crc(g_7, "g_7", print_hash_value);
  transparent_crc(g_10, "g_10", print_hash_value);
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 3; j++) {
      for (k = 0; k < 1; k++) {
 transparent_crc(g_33[i][j][k], "g_33[i][j][k]", print_hash_value);
 }
    }
  }
  transparent_crc(g_320.f0, "g_320.f0", print_hash_value);
  transparent_crc(g_350.f0, "g_350.f0", print_hash_value);
  transparent_crc(g_350.f1, "g_350.f1", print_hash_value);
  transparent_crc(g_350.f2, "g_350.f2", print_hash_value);
  for (i = 0; i < 6; i++) {
 transparent_crc(g_a30[i], "g_a30[i]", print_hash_value);
  }
  for (i = 0; i < 6; i++) {
    transparent_crc(g_b30[i], "g_b30[i]", print_hash_value);
  }
  platform_main_end(crc32_context ^ 0xFFFFFFFFUL, print_hash_value);
  return 0;
}

```

**file2.c**
```

#include "csmith.h"

static int32_t g_a30[6];
static int64_t g_b30[6];

struct S0 {
  const volatile uint32_t f0;
  uint64_t f1;
  int64_t f2;
};

union U1 {
  int16_t f0;
  uint16_t f1;
  uint16_t f2;
  const struct S0 f3;
};

static volatile int32_t g_7 = 0x6B471DFDL;
static int32_t g_10 = 1L;
static int32_t g_33[2][3][1] = {{{(-7L)}, {(-7L)}, {(-7L)}}, {{(-7L)}, {(-7L)}, {(-7L)}}};
static volatile union U1 g_320 = {1L};
static volatile union U1 *g_319 = &g_320;
static volatile union U1 *volatile *const g_318 = &g_319;
static struct S0 g_350 = {2UL, 18446744073709551615UL, 0x484C2F172B251D2FLL};

static const void func_1(void);

static const void func_1(void) {
  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 <= 6; ij_0++) {
    if (ij_0 <= 3 && i < 3) {
      g_a30[ii_0] = g_7 * g_10 + (**g_318).f1;
      i++;
      ii_0++;
    }
    if (ij_0 <= 6 && jj_0 < 6) {
      g_b30[jj_0] = g_33[1][1][0] * g_a30[jj_0] + g_350.f2;
      jj_0++;
    }
  }
}

int main(void) {
 int i, j, k;
  int print_hash_value = 0;
  platform_main_begin();
 crc32_gentab();
  func_1();
  transparent_crc(g_7, "g_7", print_hash_value);
  transparent_crc(g_10, "g_10", print_hash_value);
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 3; j++) {
      for (k = 0; k < 1; k++) {
 transparent_crc(g_33[i][j][k], "g_33[i][j][k]", print_hash_value);
 }
    }
  }
  transparent_crc(g_320.f0, "g_320.f0", print_hash_value);
  transparent_crc(g_350.f0, "g_350.f0", print_hash_value);
  transparent_crc(g_350.f1, "g_350.f1", print_hash_value);
  transparent_crc(g_350.f2, "g_350.f2", print_hash_value);
  for (i = 0; i < 6; i++) {
 transparent_crc(g_a30[i], "g_a30[i]", print_hash_value);
  }
  for (i = 0; i < 6; i++) {
    transparent_crc(g_b30[i], "g_b30[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/eJzsWV1v8joS_jXmZkSUjPMBF1zwUXQq9agrnXOukUkcMHUSNnFou79-ZSchIYS2b7uvtBcgRDzj-XjsGbsPhRWF2KWcz4i3IN5qxEq1z_LZg8xeeTo-HF5H2yx6n62zHNSeQ5xJmb2KdAfqNYMQYiF5QXAJj3DkeZzlCY-MIf93KU5M8lSBylla6CmmRJZCFoPMsiPEeZYAwTnBuY7iWGElgMo6amzUFjxCzlIdvOAmu8kNOS-OPFTixOU7lIWGFok45rlOnR2VSMR_qsSSn7gsQKShLCNtVwUeP9vVQC-jUTnXKrxW0WtVca2KWaGaNfytt-aNhQ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