Commit be9df76
Extend the "skip-test" optimization to all instructions that modify the (#120876)
Extend the "skip-test" optimization to all instructions that modify the
same flags as "TEST" x86 instruction
Originally wanted to only cover the "POPCNT" case, but actually we can
go further than that and cover more instructions.
Fixes #118811
Using the following code:
```csharp
static void M1(int value)
{
if (int.PopCount(value) > 0)
throw null!;
}
```
This fix reduces this assembly:
```asm
popcnt edi, edi
test edi, edi
jg SHORT G_M9581_IG04
```
to this assembly:
```asm
popcnt edi, edi
jg SHORT G_M000_IG04
```
Note: this is not exactly as was intended in the issue, where a `jne`
was expected. But that should be good enough.
Note2: this does not affect `tnzcnt` or `lzcnt` instructions as these
instructions do not modify the flags.
Co-authored-by: Lotendan <letupertinois@hotmail.fr>1 parent 78315b9 commit be9df76
1 file changed
+11
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9196 | 9196 | | |
9197 | 9197 | | |
9198 | 9198 | | |
9199 | | - | |
| 9199 | + | |
| 9200 | + | |
| 9201 | + | |
| 9202 | + | |
9200 | 9203 | | |
9201 | 9204 | | |
9202 | 9205 | | |
9203 | 9206 | | |
9204 | 9207 | | |
| 9208 | + | |
9205 | 9209 | | |
9206 | 9210 | | |
9207 | 9211 | | |
9208 | 9212 | | |
9209 | 9213 | | |
| 9214 | + | |
| 9215 | + | |
| 9216 | + | |
9210 | 9217 | | |
9211 | 9218 | | |
9212 | 9219 | | |
9213 | 9220 | | |
| 9221 | + | |
9214 | 9222 | | |
9215 | 9223 | | |
9216 | 9224 | | |
9217 | 9225 | | |
9218 | 9226 | | |
9219 | 9227 | | |
9220 | | - | |
| 9228 | + | |
| 9229 | + | |
9221 | 9230 | | |
9222 | 9231 | | |
9223 | 9232 | | |
| |||
0 commit comments