@@ -2079,12 +2079,14 @@ uint LoadNode::match_edge(uint idx) const {
20792079// with the value stored truncated to a byte. If no truncation is
20802080// needed, the replacement is done in LoadNode::Identity().
20812081//
2082- Node * LoadBNode::Ideal (PhaseGVN * phase, bool can_reshape) {
2082+ Node* LoadBNode::Ideal (PhaseGVN* phase, bool can_reshape) {
20832083 Node* mem = in (MemNode::Memory);
20842084 Node* value = can_see_stored_value (mem,phase);
2085- if ( value && !phase->type (value)->higher_equal ( _type ) ) {
2086- Node *result = phase->transform ( new LShiftINode (value, phase->intcon (24 )) );
2087- return new RShiftINode (result, phase->intcon (24 ));
2085+ if (value != NULL ) {
2086+ Node* narrow = Compile::narrow_value (T_BYTE, value, _type, phase, false );
2087+ if (narrow != value) {
2088+ return narrow;
2089+ }
20882090 }
20892091 // Identity call will handle the case where truncation is not needed.
20902092 return LoadNode::Ideal (phase, can_reshape);
@@ -2114,8 +2116,12 @@ const Type* LoadBNode::Value(PhaseGVN* phase) const {
21142116Node* LoadUBNode::Ideal (PhaseGVN* phase, bool can_reshape) {
21152117 Node* mem = in (MemNode::Memory);
21162118 Node* value = can_see_stored_value (mem, phase);
2117- if (value && !phase->type (value)->higher_equal (_type))
2118- return new AndINode (value, phase->intcon (0xFF ));
2119+ if (value != NULL ) {
2120+ Node* narrow = Compile::narrow_value (T_BOOLEAN, value, _type, phase, false );
2121+ if (narrow != value) {
2122+ return narrow;
2123+ }
2124+ }
21192125 // Identity call will handle the case where truncation is not needed.
21202126 return LoadNode::Ideal (phase, can_reshape);
21212127}
@@ -2141,11 +2147,15 @@ const Type* LoadUBNode::Value(PhaseGVN* phase) const {
21412147// with the value stored truncated to a char. If no truncation is
21422148// needed, the replacement is done in LoadNode::Identity().
21432149//
2144- Node * LoadUSNode::Ideal (PhaseGVN * phase, bool can_reshape) {
2150+ Node* LoadUSNode::Ideal (PhaseGVN* phase, bool can_reshape) {
21452151 Node* mem = in (MemNode::Memory);
21462152 Node* value = can_see_stored_value (mem,phase);
2147- if ( value && !phase->type (value)->higher_equal ( _type ) )
2148- return new AndINode (value,phase->intcon (0xFFFF ));
2153+ if (value != NULL ) {
2154+ Node* narrow = Compile::narrow_value (T_CHAR, value, _type, phase, false );
2155+ if (narrow != value) {
2156+ return narrow;
2157+ }
2158+ }
21492159 // Identity call will handle the case where truncation is not needed.
21502160 return LoadNode::Ideal (phase, can_reshape);
21512161}
@@ -2171,12 +2181,14 @@ const Type* LoadUSNode::Value(PhaseGVN* phase) const {
21712181// with the value stored truncated to a short. If no truncation is
21722182// needed, the replacement is done in LoadNode::Identity().
21732183//
2174- Node * LoadSNode::Ideal (PhaseGVN * phase, bool can_reshape) {
2184+ Node* LoadSNode::Ideal (PhaseGVN* phase, bool can_reshape) {
21752185 Node* mem = in (MemNode::Memory);
21762186 Node* value = can_see_stored_value (mem,phase);
2177- if ( value && !phase->type (value)->higher_equal ( _type ) ) {
2178- Node *result = phase->transform ( new LShiftINode (value, phase->intcon (16 )) );
2179- return new RShiftINode (result, phase->intcon (16 ));
2187+ if (value != NULL ) {
2188+ Node* narrow = Compile::narrow_value (T_SHORT, value, _type, phase, false );
2189+ if (narrow != value) {
2190+ return narrow;
2191+ }
21802192 }
21812193 // Identity call will handle the case where truncation is not needed.
21822194 return LoadNode::Ideal (phase, can_reshape);
0 commit comments