microblaze: Fix -Os right shift optimization is allowed into delay slot #37
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
During picolibc testing, it's found that
-Os
produces assembly code that compilersqueezes into a single delay slot. Thus, only the first instruction emitted by this optimization is run and the rest is skipped.
Optimization is generated by
But
arith
type is NOT disallowed from going into delay slot (see below):gcc/gcc/config/microblaze/microblaze.md
Line 466 in 428d8d7
"Optimized" code is between [191b8-191c8]
where
operands
are:As a result, this code returns a
iy
(r24
) value of (whatever was in r24) - 1023`The fix is simple. I've redeclared this size-optimization as
multi
which isgcc/gcc/config/microblaze/microblaze.md
Line 2070 in 428d8d7
gcc/gcc/config/microblaze/microblaze.md
Line 2483 in 428d8d7
For context, non-size-optimized code is
N
copies of:And as per the above optimization rule, if
N <= 5
we'll still get 5 copies ofsra
instruction.Currently under test via zephyrproject-rtos/sdk-ng#647