<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/75595>75595</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        C20624F         1411B9B7        C20624F         C20624F C20624F         C20624F      
file2.c        C20624F         1411B9B7 C20624F         C20624F         1411B9B7        C20624F 
```
 
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_a0[2];
static uint64_t g_b0[2];

static uint64_t g_9 = 1UL;
static int32_t g_11 = 0x6B471DFDL;
static int8_t g_19 = 0x49L;

static void func_1(void);

static void func_1(void) {
  int32_t l_14 = 0x0E864896L;
  int i;
  int ii_0;
  // fusion
  for (i = 0, ii_0 = 0; i < 1; i++, ii_0++) {
    g_a0[ii_0] = g_19 * l_14 + g_11;
  }
 int jj_0;
  for (jj_0 = 0; jj_0 < 2; jj_0++) {
    g_b0[jj_0] = g_19 * g_a0[jj_0] + g_9;
  }
}

int main(void) {
  int i;
  int print_hash_value = 0;
  platform_main_begin();
  crc32_gentab();
 func_1();
  transparent_crc(g_9, "g_9", print_hash_value);
 transparent_crc(g_11, "g_11", print_hash_value);
  transparent_crc(g_19, "g_19", print_hash_value);
  for (i = 0; i < 2; i++) {
 transparent_crc(g_a0[i], "g_a0[i]", print_hash_value);
  }
  for (i = 0; i < 2; i++) {
    transparent_crc(g_b0[i], "g_b0[i]", print_hash_value);
  }
  platform_main_end(crc32_context ^ 0xFFFFFFFFUL, print_hash_value);
  return 0;
}
```

**file2.c**
```

#include "csmith.h"

static int32_t g_a0[2];
static uint64_t g_b0[2];

static uint64_t g_9 = 1UL;
static int32_t g_11 = 0x6B471DFDL;
static int8_t g_19 = 0x49L;

static void func_1(void);

static void func_1(void) {
  int32_t l_14 = 0x0E864896L;
  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 <= 2; ij_0++) {
    if (ij_0 <= 1 && i < 1) {
      g_a0[ii_0] = g_19 * l_14 + g_11;
      i++;
      ii_0++;
    }
    if (ij_0 <= 2 && jj_0 < 2) {
      g_b0[jj_0] = g_19 * g_a0[jj_0] + g_9;
      jj_0++;
 }
  }
}

int i;
int main(void) {
  int print_hash_value = 0;
  platform_main_begin();
  crc32_gentab();
  func_1();
 transparent_crc(g_9, "g_9", print_hash_value);
  transparent_crc(g_11, "g_11", print_hash_value);
  transparent_crc(g_19, "g_19", print_hash_value);
  for (i = 0; i < 2; i++) {
 transparent_crc(g_a0[i], "g_a0[i]", print_hash_value);
  }
  for (i = 0; i < 2; i++) {
    transparent_crc(g_b0[i], "g_b0[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/eJzsWF2Pm7oW_TXOy1YQbCCEhzxMkok6Uqu50m2fI4eY4KmxudhMZu6vP7KBhCSkHbXnPBypaJSwP9h72V72CkO15gfJ2ILESxKvJ7QxhaoXj0IdmZy-vBwnO7V_X2xUDaZgkCsh1JHLA5ijggxyLpgmuIInqFidq7pke5fI_tfwVyqYNGBqKrUNUcOVBJWDUKqCvFYl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