Commit 850b702
committed
Fix: Only skip AND masking for unsigned narrow types in NarrowWithSaturation
The inputsAlreadyClamped optimization was incorrectly applied to all types,
but it's only valid for unsigned narrow types (TYP_UBYTE, TYP_USHORT).
For signed narrow types, the AND masking is still required to clear the
sign-extended upper bits before PackUnsignedSaturate can correctly pack
the values. Without this masking, negative values would have incorrect
upper bits that would cause PackUnsignedSaturate to produce wrong results.
This fixes System.Numerics.Tests.GenericVectorTests.NarrowWithSaturationInt32Test1 parent 3ab1a8a commit 850b702
1 file changed
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3541 | 3541 | | |
3542 | 3542 | | |
3543 | 3543 | | |
3544 | | - | |
3545 | | - | |
| 3544 | + | |
| 3545 | + | |
| 3546 | + | |
| 3547 | + | |
| 3548 | + | |
| 3549 | + | |
| 3550 | + | |
| 3551 | + | |
| 3552 | + | |
3546 | 3553 | | |
3547 | 3554 | | |
3548 | 3555 | | |
| |||
0 commit comments