Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Fixes GT_MOD codegen and three other issues for ARM64 #3390

Merged
merged 1 commit into from
Feb 27, 2016

Conversation

briansull
Copy link

Fix Issue 3263 - Incorrect codegen for rem.un - Unisgned Remainder
Fix Issue 3317 - Improve the codegen for divide so that we omit checks when we have a constant divisor
Fix Issue 3326 - assert EA_4BYTE or EA_8BYTE
Fix an assert when using alloca with allocation between 65 and 4095 bytes

Also fixed the name for GT_UDIV and GT_UDIV to contain a "un-" prefix.

@briansull
Copy link
Author

@kyulee1 PTAL
@jashook PTAL
@dotnet/jit-contrib PTAL

genJumpToThrowHlpBlk(EJ_jmp, SCK_DIV_BY_ZERO);

// We still need to produce a register result
emit->emitIns_R_R(INS_mov, size, targetReg, REG_ZR);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is dead code and follows after jmp instruction. If it is required to set targetReg to zero, shouldn't this be before genJumpToThrowHlpBlk()?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For correctness we have to call genProduceReg(treeNode);
That method handles spilling and marking something as a GC or non GC pointer.
To me it make sense to put an updated value into the destination register rather than leave a possibly uninitialized value there. The extra code size of one instruction for the case of an explicit division by the constant zero is a negligible cost to prevent a possible GC pointer information leak.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Div operation never produces a gc-ref. Besides both code emitted by emitins_R_R() and the code produced by genProduceReg() both are dead code and will never get executed. From that perspective setting targetReg to zero isn't serving any purpose.

I understand genProduceReg() call is still required for updating the life of targetReg but i don't see why we need to emit an instruction to set targetReg to zero. That was my point

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, after talking with you I will remove the mov targetReg, ZR instruction

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, are we sure that codegen needs to handle divisor being a constant integer zero? Isn't morph ensuring div-by-zero gets morphed into a 'Throw' so that the basic block will be marked to end with a throw and that might lead to dead code elimination?

If front-end ensures the invariant that backend never sees div-by-zero constant, we just need to add an assert here.

@sivarv
Copy link
Member

sivarv commented Feb 26, 2016

Looks good.

@jashook
Copy link

jashook commented Feb 26, 2016

LGTM

@kyulee1
Copy link

kyulee1 commented Feb 27, 2016

LGTM

Fix Issue 3263 - Incorrect codegen for rem.un - Unisgned Remainder
Fix Issue 3317 - Improve the codegen for divide so that we omit checks when we have a constant divisor
Fix Issue 3326 - assert EA_4BYTE or EA_8BYTE
Fix an assert when using alloca with allocation between 65 and 4095 bytes

Also fixed the name for GT_UDIV and GT_UDIV to contain a "un-" prefix.
Added 10 additional passing tests with tag REL_PASS
briansull added a commit that referenced this pull request Feb 27, 2016
Fixes GT_MOD codegen and three other issues for ARM64
@briansull briansull merged commit 420d6fa into dotnet:master Feb 27, 2016
@briansull briansull deleted the mod-fixes branch February 27, 2016 01:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants