-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Expand GT_JCC/SETCC condition support #17733
Conversation
927df3c
to
646f00a
Compare
This produces some small jit diffs:
All diffs are due to a change in |
In an attempt to get better validation for this change (the JIT doesn't currently produce a lot of JCC/SETCC nodes) I made various experiments:
Code can be found in https://github.com/mikedn/coreclr/commits/cc-cond2-exp. It's not 100% complete/accurate/correct etc. but at least tests pass. |
Very Nice! |
assert(INS_jpe + (INS_l_jmp - INS_jmp) == INS_l_jpe); | ||
assert(INS_jpo + (INS_l_jmp - INS_jmp) == INS_l_jpo); | ||
assert(INS_jp + (INS_l_jmp - INS_jmp) == INS_l_jp); | ||
assert(INS_jnp + (INS_l_jmp - INS_jmp) == INS_l_jnp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Intel arch does define both jp and jpe, I don't think that we even use these instructions but it seems to me that jpe and jpo are more understandable than jp and jnp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO jpe/jpo are more understandable when used for the original purpose - parity checking. But that's history now and the only purpose of the PF flag these days is detecting "unordered" floating point comparisons. In this case jp/jnp seem preferable because the clearly indicate that the branch is taken when PF=1/0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VS's own disassembler also uses jp/jnp:
00007FFD026C049F C4 E1 7B 10 05 E8 42 EF FF vmovsd xmm0,qword ptr [7FFD025B4790h]
00007FFD026C04A8 C4 E1 79 2E 05 E7 42 EF FF vucomisd xmm0,mmword ptr [7FFD025B4798h]
00007FFD026C04B1 7A 02 jp 00007FFD026C04B5
00007FFD026C04B3 74 0B je 00007FFD026C04C0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I am good with this change.
Thanks for the explaination.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks Good
This is also lays the groundwork for generating CMOV, right? |
I wouldn't say it's groundwork but it certainly helps. Without it, CMOV would likely be more limited (e.g. no floating point conditions or no ability to handle condition flags set by BT). Of course, none of this deals with the thorny question of representing condition flags data flow explicitly. But unless the JIT starts doing fancy optimizations post lowering that's not much of an issue. |
@dotnet-bot test OSX10.12 x64 Checked Innerloop Build and Test |
eb4ee02
to
933dbd2
Compare
The odd/even meaning is irrelevant and potentially confusing - is P set for even or for odd?
@dotnet-bot test this please |
@briansull @AndyAyersMS Do you want to re-review this? @mikedn Is there any reason this has been sitting for so long, except for us not being responsive? I.e., is it ready to merge, if tests pass (again)? |
@BruceForstall Yes, it's ready to merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks Good Again
Expand GT_JCC/SETCC condition support Commit migrated from dotnet/coreclr@459b58a
Currently GT_JCC/SETCC nodes use relops as condition codes and this prevents the use of flag specific conditions (e.g. S, NS, P, NP) and floating point conditions. Additionally, the code used by GT_JTRUE and relop codegen is rather convoluted and not very easy to reuse for GT_JCC/SETCC codegen.
This changes GT_JCC/SETCC's condition to
GenCondition
, a class that can encode all necessary conditions - signed/unsigned integral conditions, ordered/unordered floating point conditions and flag specific conditions. Mapping betweenGenCondition
codes and emitter jump kinds is done via arch specific tables instead ofgenJumpKindForOper
andgenJumpKindsForTree
.GT_JTRUE codegen has been updated to also use
GenCondition
so thatgenJumpKindForOper
andgenJumpKindsForTree
can be removed.Contributes to #17073