<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/96156>96156</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[BUG][Clang][AArch64] LLVM backend error: Invalid size request on a scalable vector.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
toor1245
</td>
</tr>
</table>
<pre>
The Clang compiler, LLVM reports error "fatal error: error in backend: Invalid size request on a scalable vector." starting from version 17.0.1 with the following compiler options:
`-march=armv9-a` and higher (armv9.1-a, armv9.2-a, armv9.3-a and so on) and `-mstrict-align` and optimization flags like `-Os`, `-O2`
### Notes when it works successfully:
* When Optimization flag: `-O0`, `-O1`, `-O3`, example https://gcc.godbolt.org/z/4ojzoz9jP
* Without `-mstrict-align` flag, example https://gcc.godbolt.org/z/7MbqGfoe8
* Without any optimization flags and specified `-mstrict-align` with `-march=armv9-a`, example https://gcc.godbolt.org/z/e7q1bv498
* When target architecture from `armv8-a` to `armv8.9-a`, example https://gcc.godbolt.org/z/q6eobPPPx
* When loop iteration count not power of 2, for example, `array_size` is `127` - https://gcc.godbolt.org/z/d7rKvdboG
### armv8-a clang (trunk) - Failed
* https://gcc.godbolt.org/z/9r5Mva8oe
### armv8-a clang 18.1.0 - Failed
* https://gcc.godbolt.org/z/747e3hd7h
### armv8-a clang 17.0.1 - Failed
* https://gcc.godbolt.org/z/zMW4hWGhW
### armv8-a clang 16.0.0 - No problem
* https://gcc.godbolt.org/z/nr9a9EhM5
## Steps to reproduce the issue.
```c
#include <stdint.h>
#include <stdlib.h>
uint64_t *InvalidSizeRequestOnScalableVector()
{
uint64_t value = 30;
uint64_t array_size = 128;
uint64_t *array = (uint64_t *) malloc(sizeof(uint64_t) * array_size);
for (unsigned long i = 0; i < array_size; i++)
{
array[i] = value;
}
return array;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llv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