View Revisions: Issue #38985

Summary 0038985: [Patch] Faulty conditional jump logic
Revision 2021-06-10 23:02 by J. Gareth Moreton
Description This patch fixes some faulty jump logic in the "Dominated conditional jump" and the "condition_in" function. The following are fixed:

- The "Dominated conditional jump" had the subset check between the two jumps back-to-front.
- The "jmp<cond> before jmp<inv_cond>" had the subset check between the two jumps back-to-front, and wasn't quite correct in cases where <inv_cond> was a subset of the 2nd jump's conditions (rather than being exactly the same).
- "RemoveInstruction" and "RemoveCurrentP" inserted in the global jump optimisations where possible to reduce code maintenance.

x86-specific:

- "condition_in" incorrectly said "NE" was a subset of "L", "G", "A" and "B" (for example, if %reg = 0 and "cmp $1,%reg" is called, jne will branch, but jg will not. Treat "not equal" as equivalent to "less than OR greater than" or "above OR below").
- "condition_in" didn't consider "A", "B", "L" and "G" to be subsets of "NE".
- "condition_in" didn't consider "A" and "AE" to be subsets of "NC" (in regards to checking flags, B and C (and NB and NC) are interchangeable).
- "condition_in" incorrectly said "E" was a subset of "NB" (though logically sound when it comes to comparing numerical values, the conditions don't share flags. That is, E checks ZF = 0, while NB/NC check CF = 0).
Revision 2021-06-10 23:01 by J. Gareth Moreton
Description This patch fixes some faulty jump logic in the "Dominated conditional jump" and the "condition_in" function. The following are fixed:

- The "Dominated conditional jump" had the subset check between the two jumps back-to-front.
- The "jmp<cond> before jmp<inv_cond>" had the subset check between the two jumps back-to-front, and wasn't quite correct in cases where <inv_cond> was a subset of the 2nd jump's conditions (rather than being exactly the same).
- "RemoveInstruction" and "RemoveCurrentP" inserted in the global jump optimisations where possible to reduce code maintenance.

x86-specific:

- "condition_in" incorrectly said "NE" was a subset of "L", "G", "A" and "B" (for example, if %reg = 0 and "cmp $1,%reg" is called, jne will branch, but jg will not. Treat "not equal" as equivalent to "less than OR greater than" or "above OR below").
- "condition_in" didn't consider "A", "B", "L" and "G" to be subsets of "NE".
- "condition_in" didn't consider "A" and "AE" to be subsets of "NC" (in regards to checking flags, B and C (and NB and NC) are interchangeable).
- "condition_in" incorrectly said "E" was a subset of "NB" and "NC" (though logically sound, the conditions don't share flags. That is, E checks ZF = 0, while NB/NC check CF = 0).
Revision 2021-06-10 22:54 by J. Gareth Moreton
Description This patch fixes some faulty jump logic in the "Dominated conditional jump" and the "condition_in" function. The following are fixed:

- The "Dominated conditional jump" had the subset check between the two jumps back-to-front.
- The "jmp<cond> before jmp<inv_cond>" had the subset check between the two jumps back-to-front, and wasn't quite correct in cases where <inv_cond> was a subset of the 2nd jump's conditions (rather than being exactly the same).
- "RemoveInstruction" and "RemoveCurrentP" inserted in the global jump optimisations where possible to reduce code maintenance.

x86-specific:

- "condition_in" on x86 incorrectly said "NE" was a subset of "L", "G", "A" and "B" (for example, if %reg = 0 and "cmp $1,%reg" is called, jne will branch, but jg will not. Treat "not equal" as equivalent to "less than OR greater than" or "above OR below").
- "condition_in" on x86 didn't consider "A", "B", "L" and "G" to be subsets of "NE".
- "condition_in" on x86 didn't consider "A" and "AE" to be subsets of "NC" (in regards to checking flags, B and C (and NB and NC) are interchangeable).
Revision 2021-06-10 22:49 by J. Gareth Moreton
Description This patch fixes some faulty jump logic in the "Dominated conditional jump" and the "condition_in" function. The following are fixed:

- The "Dominated conditional jump" had the subset check between the two jumps back-to-front.
- The "jmp<cond> before jmp<inv_cond>" had the subset check between the two jumps back-to-front, and wasn't quite correct in cases where <inv_cond> was a subset of the 2nd jump's conditions (rather than being exactly the same).

x86-specific:

- "condition_in" on x86 incorrectly said "NE" was a subset of "L", "G", "A" and "B" (for example, if %reg = 0 and "cmp $1,%reg" is called, jne will branch, but jg will not. Treat "not equal" as equivalent to "less than OR greater than" or "above OR below").
- "condition_in" on x86 didn't consider "A", "B", "L" and "G" to be subsets of "NE".
- "RemoveInstruction" and "RemoveCurrentP" inserted in the global jump optimisations where possible to reduce code maintenance.