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

[Jit] fgMorphCast does not reset GTF_ASG #14102

Merged
merged 3 commits into from
Sep 21, 2017

Conversation

sandreenko
Copy link

@sandreenko sandreenko commented Sep 20, 2017

In the issue during the assertion propagation phase fgMorph transforms such IL:

     (154, 98) [000071] ------------             *  STMT      void
+N038 (154, 98) [000066] -ACXG-------             \--*  CAST_ovfl int <- short <- int $313
+N037 (147, 90) [000065] -ACXG-------                \--*  CAST_ovfl int <- byte <- int $310
+N036 (140, 82) [000134] -ACXG-------                   \--*  CALL help int    HELPER.CORINFO_HELP_DBL2INT_OVF $30d
N032 (  1,  2) [000042] ------------                      |     /--*  CNS_DBL   double 0.00000000000000000 $140
N033 ( 57, 26) [000050] ------------                      |  /--*  ADD       double $385
N031 ( 51, 20) [000049] ------------                      |  |  \--*  CAST      double <- float $384
N030 ( 45, 14) [000048] ------------                      |  |     \--*  NEG       float  $480
N029 ( 44, 13) [000047] ------------                      |  |        \--*  CAST      float <- double $441
N028 ( 38,  7) [000046] ------------                      |  |           \--*  CNS_DBL   double -1.#IND000000000000 $141
N034 (126, 76) [000064] -ACXG------- arg0 in mm0          \--*  ADD       double $387
N025 ( 64, 46) [000063] -ACXG-------                         \--*  CAST      double <- long $383
N021 (  1,  1) [000163] ------------                            |        /--*  LCL_VAR   int    V11 cse1          $30c
N022 (  4,  5) [000164] -A----------                            |     /--*  COMMA     int    $30c
N018 (  3,  4) [000147] ------------                            |     |  |  /--*  CAST      int <- ubyte <- int $30c
N017 (  2,  2) [000059] ------------                            |     |  |  |  \--*  LCL_VAR   int    V00 arg0         u:2 $80
N020 (  3,  4) [000162] -A------R---                            |     |  \--*  ASG       int    $VN.Void
N019 (  1,  1) [000161] D------N----                            |     |     \--*  LCL_VAR   int    V11 cse1          $30c
N023 ( 35, 26) [000060] -ACX--------                            |  /--*  RSZ       long   $3c5
N016 ( 27, 20) [000058] --CX--------                            |  |  \--*  CALL help long   HELPER.CORINFO_HELP_DBL2LNG_OVF $3c3
N014 ( 13, 14) [000143] ------------ arg0 in mm0                |  |     \--*  CNS_DBL   double 0.00000000000000000 $140
N024 ( 58, 40) [000062] -ACXG-------                            \--*  MUL_ovfl  long   $3c6
+N008 (  1,  1) [000159] ------------                               |  /--*  CNS_INT   long   0 $340
+N009 ( 16,  8) [000160] --CXG-------                               \--*  COMMA     long   $30b
+N007 ( 15,  7) [000139] --CXG-------                                  \--*  CALL help void   HELPER.CORINFO_HELP_OVERFLOW $2c5
+N005 (  1,  1) [000137] ------------ arg0 in rcx                         \--*  CNS_INT   int    0 $40

into

N013 ( 44, 30) [000066] -ACXG-------             *  CAST_ovfl int <- short <- int $313
N012 ( 37, 22) [000065] -ACXG-------             \--*  CAST_ovfl int <- byte <- int $310
N011 ( 30, 14) [000134] --CXG-------                \--*  CALL help int    HELPER.CORINFO_HELP_DBL2INT_OVF $30d
N008 (  1,  1) [000159] ------------                   |  /--*  CNS_DBL   double 0.00000000000000000 $140
N009 ( 16,  8) [000160] --CXG------- arg0 in mm0       \--*  COMMA     double $30b
N007 ( 15,  7) [000139] --CXG-------                      \--*  CALL help void   HELPER.CORINFO_HELP_OVERFLOW $2c5
N005 (  1,  1) [000137] ------------ arg0 in rcx             \--*  CNS_INT   int    0 $40

The problem is that 000065 should not have the ASG flag after that morphing.
The tree undo 000060 is deleted because the left child 000160 always throws an exception.

@sandreenko
Copy link
Author

PTAL @dotnet/jit-contrib

Copy link

@briansull briansull left a comment

Choose a reason for hiding this comment

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

LGTM

Nice simple fix

@@ -502,6 +502,9 @@ GenTreePtr Compiler::fgMorphCast(GenTreePtr tree)
/* Reset the call flag */
tree->gtFlags &= ~GTF_CALL;

/* Reset the assignment flag */
tree->gtFlags &= GTF_ASG;
Copy link
Member

Choose a reason for hiding this comment

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

You forgot ~ before GTF_ASG.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@erozenfeld erozenfeld left a comment

Choose a reason for hiding this comment

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

LGTM

@sandreenko sandreenko merged commit 1c2407a into dotnet:master Sep 21, 2017
@sandreenko sandreenko deleted the fix_DevDiv_495792 branch September 21, 2017 21:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants