https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118279
--- Comment #5 from Andrew Macleod <amacleod at redhat dot com> ---
Is this an RTL issue?
the testcase as it is has no way of showing the hoff is [0,2].. If I add the
suggested
if (hoff > 2 || hoff < 0)
__builtin_unreachable();
before the loop, the vrp figures out that the range of the switch index is
[0,5] and there is no longer an unreachable case.
When we go the .optimized listing:
<L29>:
_8 = header_byte_25 >> 2;
_30 = _8 & 3;
_9 = (int) _30;
_10 = _9 + hoff_22(D);
switch (_10) <default: <L23> [0.00%], case 1: <L18> [40.00%], case 2: <L19>
[20.00%], case 3: <L20> [20.00%], case 4: <L21> [20.00%], case 5: <L18>
[40.00%]>
<bb 9> [local count: 191030483]:
goto <bb 13>; [100.00%]
<bb 10> [local count: 191030483]:
goto <bb 13>; [100.00%]
<bb 11> [local count: 191030483]:
goto <bb 13>; [100.00%]
<bb 12> [local count: 191030483]:
<bb 13> [local count: 955630225]:
# _65 = PHI <_76(8), _55(9), _59(10), _63(11), _64(12)>
<L23>:
_11 = header_byte_25 >> 4;
_28 = _11 & 3;
_12 = (int) _28;
_13 = _12 + hoff_22(D);
switch (_13) <default: <L17> [0.00%], case 1: <L12> [40.00%], case 2: <L13>
[20.00%], case 3: <L14> [20.00%], case 4: <L15> [20.00%], case 5: <L12>
[40.00%]>
L18>:
The switches simply feed into the next switch, so at the tree level I'm not
sure what guard there is unless RTL is producing it.
Or am I missing something?
Oh and without the added check on hoff, we keep the builtin_unreachable case...
and I notice the call still exists in the .optimized code as a case.... Are
we actually suppose to keep that in the IL? is it related to that maybe?