FPC 3.3.1 compiler internal exception with -O3 (works with 3.2.2)
## Summary
The code bellow is a simplified copy of `PrimeFactors` from [JCLMath.pas](https://github.com/project-jedi/jcl/blob/master/jcl/source/common/JclMath.pas). It compiles with success using FPC 3.2.2, but it raises an Access Violation exception if compiled with -O3 optimization and FPC 3.3.1 (commit 4f9acc10f092a6a59a8c213ca29c08227ee1ab61 from 2022-07-19) on Linux.
## System Information
- **Operating system:** Linux Ubuntu 20.04
- **Processor architecture:** x86-64
- **Compiler version:** 3.3.1 (main branch compiled using FPC 3.2.2)
- **Device:** Computer
## Steps to reproduce
```
program project1;
{.$mode delphi}
{$mode objfpc}{$H+}
type
TDynCardinalArray = array of Cardinal;
function Test(N: Cardinal): TDynCardinalArray;
var
L: Cardinal;
begin
SetLength(Result, 0);
if N <= 1 then
Exit
else
begin
L := 0;
if N mod 2 = 0 then
begin
Inc(L);
SetLength(Result, L);
Result[L - 1] := 2;
end;
Inc(L);
SetLength(Result, L);
Result[L - 1] := N;
end;
end;
begin
Test(2);
WriteLn('OK');
end.
```
## What is the current bug behavior?
Compilation error:
```
Compile Project, Target: project1: Exit code 1, Errors: 3
Error: An unhandled exception occurred at $000000000058CE3B:
Error: EAccessViolation: Access violation
project1.pas(12,1) Error: Compilation raised exception internally
```
## What is the expected (correct) behavior?
No compilation errors.
issue