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

    <tr>
        <th>Summary</th>
        <td>
            A/F:`isa<To>(Val) && "cast<Ty>() argument of incompatible type!"'
        </td>
    </tr>

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

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

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

<pre>
    One of our internal test suites recently had a bunch of tests start to fail with an assertion failure which I bisected back to commit b20ccccda22b1465b54bd069bd53a0a96224f3ec. Consider the following code:
```c++
typedef short __attribute__((ext_vector_type(6))) short16;
typedef union {
  short16 a;
  long b;
} union_short16_ll4;
#define union_short16_ll4_a(__A) (__A.a)
#define short16_or(__A, __B) (__A || __B)
#define short16_inv(__A) (~__A)
short16 test111_id23299;
void test111() {
  union_short16_ll4 id23298;
  id23298.b = 5;
  short16 id23297 union_short16_ll4_a(id23298);
  short16 id23296 short16_or(id23297, test111_id23299);
  volatile short16 id23295 short16_inv(id23296);

```
When compiled with optimizations using a compiler that includes b20ccccda22b1465b54bd069bd53a0a96224f3ec, the compilation fails with the following assertion failure:
```
clang++: /root/llvm-project/llvm/include/llvm/Support/Casting.h:579: decltype(auto) llvm::cast(From*) [with To = llvm::Instruction; From = llvm::Value]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
```
You can see the crash on godbolt here: https://godbolt.org/z/4rzPfnP4K
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0Vc2O6zYPfRpmQ3yBLfknXniRSb4AF130Ar24RVeGLNGxWkUKJHmmcxd99kJ2PD-ZDtBNAS9s8hxS54hMRAj6bIlaKB-gPG7EFEfnW_U82fOmd-q5_dkSugHd5FHbSN4Kg5FCxDDpSAE9SbLRPOMoFArsJyvHREiYgCEKHzE6HIQ2-KTjiMKiCIF81M7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