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

    <tr>
        <th>Summary</th>
        <td>
            unexpected output results in fusion using -O1
        </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       88CB41A7        F0C18576        42F2CD83        42F2CD83 F0C18576        42F2CD83     
file2.c       88CB41A7        88CB41A7 42F2CD83        42F2CD83        F0C18576        42F2CD83     
```
 
Please help me to explain why these two files produced different output results when using the same optimization level(i.e. -O1), 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 long __undefined;
static int32_t g_a0[1];
static int64_t g_b0[1];

union U0 {
  const volatile uint32_t f0;
  volatile uint16_t f1;
};

static int16_t g_6 = 0x3C63L;
static int16_t g_7 = 0L;
static uint16_t g_16 = 0xCF25L;
static int32_t g_28 = 0x9D70CADDL;
static int16_t g_36 = 0xEFEDL;
static volatile uint64_t g_40 = 0x8CBD6CD538770CE4LL;
static uint8_t g_70[2] = {0x13L, 0x13L};
static int32_t g_112 = 0x375EFDD8L;
static int64_t g_143[2] = {0xE94C56F68EFB8CC5LL, 0xE94C56F68EFB8CC5LL};
static int32_t g_144 = 0x7A3D7248L;
static uint16_t g_146[3] = {0xA39AL, 0xA39AL, 0xA39AL};
static int64_t g_284[3][2] = {{0xE1E09E583A3E19EALL, 0xE1E09E583A3E19EALL}, {(-2L), 0xE1E09E583A3E19EALL}, {0xE1E09E583A3E19EALL, (-2L)}};
static int32_t *g_306 = &g_112;
static int32_t **g_305 = &g_306;

static void func_1(void);

static void func_1(void) {
  int32_t *l_259 = &g_112;
  uint16_t l_317 = 1UL;
  uint64_t l_319 = 18446744073709551608UL;
  int i, j;
  int ii_0;
  // fusion
  for (i = 0, ii_0 = 0; i < 1; i++, ii_0++) {
    g_a0[ii_0] = g_70[0] * g_112 - g_144;
  }
  int jj_0;
  for (jj_0 = 0; jj_0 < 1; jj_0++) {
 g_b0[jj_0] = g_143[1] * g_a0[jj_0] + g_7;
  }
  (**g_305) = (((((g_112 > ((g_284[0][1] &= ((safe_sub_func_uint8_t_u_u((safe_add_func_uint16_t_u_u(((*l_259) || g_146[0]), 0UL)), g_6)) < l_317)) | (*l_259))) | l_319), (*l_259)) & 255UL) ^ g_28);
}

int main(void) {
  int i, j;
  int print_hash_value = 0;
  platform_main_begin();
  crc32_gentab();
  func_1();
 transparent_crc(g_6, "g_6", print_hash_value);
  transparent_crc(g_7, "g_7", print_hash_value);
  transparent_crc(g_16, "g_16", print_hash_value);
  transparent_crc(g_28, "g_28", print_hash_value);
  transparent_crc(g_36, "g_36", print_hash_value);
  transparent_crc(g_40, "g_40", print_hash_value);
  for (i = 0; i < 2; i++) {
 transparent_crc(g_70[i], "g_70[i]", print_hash_value);
  }
 transparent_crc(g_112, "g_112", print_hash_value);
  for (i = 0; i < 2; i++) {
    transparent_crc(g_143[i], "g_143[i]", print_hash_value);
 }
  transparent_crc(g_144, "g_144", print_hash_value);
  for (i = 0; i < 3; i++) {
    transparent_crc(g_146[i], "g_146[i]", print_hash_value);
  }
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 2; j++) {
      transparent_crc(g_284[i][j], "g_284[i][j]", print_hash_value);
    }
  }
  for (i = 0; i < 1; i++) {
 transparent_crc(g_a0[i], "g_a0[i]", print_hash_value);
  }
  for (i = 0; i < 1; 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 long __undefined;
static int32_t g_a0[1];
static int64_t g_b0[1];

union U0 {
  const volatile uint32_t f0;
  volatile uint16_t f1;
};

static int16_t g_6 = 0x3C63L;
static int16_t g_7 = 0L;
static uint16_t g_16 = 0xCF25L;
static int32_t g_28 = 0x9D70CADDL;
static int16_t g_36 = 0xEFEDL;
static volatile uint64_t g_40 = 0x8CBD6CD538770CE4LL;
static uint8_t g_70[2] = {0x13L, 0x13L};
static int32_t g_112 = 0x375EFDD8L;
static int64_t g_143[2] = {0xE94C56F68EFB8CC5LL, 0xE94C56F68EFB8CC5LL};
static int32_t g_144 = 0x7A3D7248L;
static uint16_t g_146[3] = {0xA39AL, 0xA39AL, 0xA39AL};
static int64_t g_284[3][2] = {{0xE1E09E583A3E19EALL, 0xE1E09E583A3E19EALL}, {(-2L), 0xE1E09E583A3E19EALL}, {0xE1E09E583A3E19EALL, (-2L)}};
static int32_t *g_306 = &g_112;
static int32_t **g_305 = &g_306;

static void func_1(void);

static void func_1(void) {
  int32_t *l_259 = &g_112;
  uint16_t l_317 = 1UL;
  uint64_t l_319 = 18446744073709551608UL;
  int i, j;
  int ii_0;
  int jj_0;
  int ij_0;
  // fusion
  for (i = 0, ii_0 = 0, jj_0 = 0, ij_0 = 0; ij_0 <= 1; ij_0++) {
    if (ij_0 <= 1 && i < 1) {
      g_a0[ii_0] = g_70[0] * g_112 - g_144;
      i++;
      ii_0++;
    }
    if (ij_0 <= 1 && jj_0 < 1) {
      g_b0[jj_0] = g_143[1] * g_a0[jj_0] + g_7;
 jj_0++;
    }
  }
  (**g_305) = (((((g_112 > ((g_284[0][1] &= ((safe_sub_func_uint8_t_u_u((safe_add_func_uint16_t_u_u(((*l_259) || g_146[0]), 0UL)), g_6)) < l_317)) | (*l_259))) | l_319), (*l_259)) & 255UL) ^ g_28);
}

int main(void) {
  int i, j;
  int print_hash_value = 0;
  platform_main_begin();
  crc32_gentab();
  func_1();
 transparent_crc(g_6, "g_6", print_hash_value);
  transparent_crc(g_7, "g_7", print_hash_value);
  transparent_crc(g_16, "g_16", print_hash_value);
  transparent_crc(g_28, "g_28", print_hash_value);
  transparent_crc(g_36, "g_36", print_hash_value);
  transparent_crc(g_40, "g_40", print_hash_value);
  for (i = 0; i < 2; i++) {
 transparent_crc(g_70[i], "g_70[i]", print_hash_value);
  }
 transparent_crc(g_112, "g_112", print_hash_value);
  for (i = 0; i < 2; i++) {
    transparent_crc(g_143[i], "g_143[i]", print_hash_value);
 }
  transparent_crc(g_144, "g_144", print_hash_value);
  for (i = 0; i < 3; i++) {
    transparent_crc(g_146[i], "g_146[i]", print_hash_value);
  }
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 2; j++) {
      transparent_crc(g_284[i][j], "g_284[i][j]", print_hash_value);
    }
  }
  for (i = 0; i < 1; i++) {
 transparent_crc(g_a0[i], "g_a0[i]", print_hash_value);
  }
  for (i = 0; i < 1; 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/eJzsWk-P4joS_zTmYoH8J_84cIAE9Ebqp15p35wjkzhgnknYxOnu2U-_suOQhISefox2TrQQ7SqXq37lqrJTEayqxCHnfAXcDXCjGavVsShXW1m883x-Or3P9kX6Y7UrSqiOHGaFlMW7yA9QvRcwgZmQvAIkhN_ghZdZUZ55agT5f2rxxiTPFVQlyys9xZQoclhkUBbFBWZlcYaArAFZay14kTQEVEWPTVr2An6DJcu18oob68Y2LHl14YkSb1z-gHWloaUiy3ipTRcXJc7iv41hyd-4rKDIE1mnWq5RPH9FzUC70bLwmEXGLDpmVWNWxirV-vCX3poPlihY1OpSKw2_lqoCJBALvoDJkSd_V_UZvjFZ651dQlZyQNcARQ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