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

    <tr>
        <th>Summary</th>
        <td>
            InstCombine miscompilation
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          bongjunj
      </td>
    </tr>
</table>

<pre>
    The following lines are executed:
https://github.com/llvm/llvm-project/blob/3de5dbb1110887d5127e815f3ca247a9d839ee85/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp#L1184-L1195

Alive2 report: https://alive2.llvm.org/ce/z/4Ht3eF

```llvm
----------------------------------------
define i8 @or_not_and_and_not_and_xor_commute2.2(i8 %a0, i8 %b, i8 %c) {
#0:
 %#1 = sdiv i8 %a0, 10
  %and1 = and i8 %b, %b
  %not1 = xor i8 %and1, 255
  %or1 = or i8 %#1, %not1
  %#2 = sdiv i8 %b, %not1
  %and2 = and i8 %#2, %#1
  %not2 = xor i8 %and2, 255
  %and3 = and i8 %or1, %not2
  ret i8 %and3
}
=>
define i8 @or_not_and_and_not_and_xor_commute2.2(i8 %a0, i8 %b, i8 %c) {
#0:
 %#1 = sdiv i8 %a0, 10
  %not1 = xor i8 %b, 255
  %or1 = or i8 %#1, %not1
  %#2 = sdiv i8 %b, %not1
  %and2 = and i8 %#2, %#1
  %and3 = xor i8 %and2, %or1
  ret i8 %and3
}
Transformation doesn't verify!

ERROR: Value mismatch

Example:
i8 %a0 = undef
i8 %b = #xbb (187, -69)
i8 %c = #x00 (0)        [based on undef value]

Source:
i8 %#1 = #x00 (0)       [based on undef value]
i8 %and1 = #xbb (187, -69)
i8 %not1 = #x44 (68)
i8 %or1 = #x44 (68)
i8 %#2 = #xff (255, -1)
i8 %and2 = #x00 (0)     [based on undef value]
i8 %not2 = #xff (255, -1)
i8 %and3 = #x44 (68)

Target:
i8 %#1 = #x00 (0)
i8 %not1 = #x44 (68)
i8 %or1 = #x44 (68)
i8 %#2 = #xff (255, -1)
i8 %and2 = #xfb (251, -5)
i8 %and3 = #xbf (191, -65)
Source value: #x44 (68)
Target value: #xbf (191, -65)

Summary:
  0 correct transformations
  1 incorrect transformations
  0 failed-to-prove transformations
  0 Alive2 errors
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMlkFv4ygUxz8NuaBE8LAT--BDO5loVxpppe5orxWY54TKhgjjTLuffoXtOG7azmbm1KptMPz85w_vQZ5sW7O3iAVJ70m6XcguHJwvlLP7p84-LZTTL8X3A9LK1bX7Yeye1sZiS6VHis9YdgE1EXeEbQm7O4RwbOMT7Ajs9iYcOrUqXUNgV9en88fy6N0TloHATtVOEdgJjalWinPOsmyjUw4bzHhaiVJCspG5zkSOmKUzHRPf--6lbSvnm5bA7k_bhi-uUcbi-OS7Mhhnh05j96vyeCQgvnGeJctvnOfpYHv4f1ebEwL1eHQ-EHFHX69G9sOrOP_K-T2BXRnn-ZfALvkjCNzNtciaDb-93b5reePPQGusjEVqMkoS5vyjdeFRWt3_ndvPzj-Wrmm6gLACAlmkIZWMwBc6tNWlWRLIKdncjwZBsClscZiA4JSILW21OdG5Emcj1XdZPWDS6vkc_ecFsy4M2LPzZzGreSQhTWeg8wM3YdHHKBhFZigBAdcO1fuotBquXMa3R7if4pVXeOsV3nqVVosrVednZuHMegwXITFu-GY7NsSWiK-fO8rvhE99ythNIXkbuzE6t4RkukZkvC6odthaAptAT-hN9UKAz8_214eHvx7i_fCPrDukjWkbGcrDK-RZNscap60_b3RvtbMaq3m_6rsJiGelKIGMZ5u4gOU6J5DPwXICGYsg68dzkt4r2aKmzg7i9BSdkXQ79_S363x5bWnKh18WvRzqW91PSRXZJInsOrtizin1E2RKpchUVWRiWsYp-RU6pdJvrm66GW6aSnzsfEwz6fcYbo3Ap9m4Sg1of7SX6c8WrnpVng_o-sIOyTdusrh73-awP6-hDxVH3a5ppH-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