Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.
/ jdk16u Public archive

Commit

Permalink
8259777: Incorrect predication condition generated by ADLC
Browse files Browse the repository at this point in the history
Reviewed-by: vlivanov, kvn
Backport-of: bcf20a0dcc752707881d3b4da25712d3ef4e93ff
  • Loading branch information
TobiHartmann committed Feb 2, 2021
1 parent f8af3b5 commit cddbb15
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
35 changes: 25 additions & 10 deletions src/hotspot/share/adlc/formssel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,7 @@ Predicate *InstructForm::build_predicate() {
for( DictI i(&names); i.test(); ++i ) {
uintptr_t cnt = (uintptr_t)i._value;
if( cnt > 1 ) { // Need a predicate at all?
int path_bitmask = 0;
assert( cnt == 2, "Unimplemented" );
// Handle many pairs
if( first ) first=0;
Expand All @@ -1530,10 +1531,10 @@ Predicate *InstructForm::build_predicate() {
// Add predicate to working buffer
sprintf(s,"/*%s*/(",(char*)i._key);
s += strlen(s);
mnode->build_instr_pred(s,(char*)i._key,0);
mnode->build_instr_pred(s,(char*)i._key, 0, path_bitmask, 0);
s += strlen(s);
strcpy(s," == "); s += strlen(s);
mnode->build_instr_pred(s,(char*)i._key,1);
mnode->build_instr_pred(s,(char*)i._key, 1, path_bitmask, 0);
s += strlen(s);
strcpy(s,")"); s += strlen(s);
}
Expand Down Expand Up @@ -3417,21 +3418,35 @@ void MatchNode::count_instr_names( Dict &names ) {
//------------------------------build_instr_pred-------------------------------
// Build a path to 'name' in buf. Actually only build if cnt is zero, so we
// can skip some leading instances of 'name'.
int MatchNode::build_instr_pred( char *buf, const char *name, int cnt ) {
int MatchNode::build_instr_pred( char *buf, const char *name, int cnt, int path_bitmask, int level) {
if( _lChild ) {
if( !cnt ) strcpy( buf, "_kids[0]->" );
cnt = _lChild->build_instr_pred( buf+strlen(buf), name, cnt );
if( cnt < 0 ) return cnt; // Found it, all done
cnt = _lChild->build_instr_pred(buf, name, cnt, path_bitmask, level+1);
if( cnt < 0 ) {
return cnt; // Found it, all done
}
}
if( _rChild ) {
if( !cnt ) strcpy( buf, "_kids[1]->" );
cnt = _rChild->build_instr_pred( buf+strlen(buf), name, cnt );
if( cnt < 0 ) return cnt; // Found it, all done
path_bitmask |= 1 << level;
cnt = _rChild->build_instr_pred( buf, name, cnt, path_bitmask, level+1);
if( cnt < 0 ) {
return cnt; // Found it, all done
}
}
if( !_lChild && !_rChild ) { // Found a leaf
// Wrong name? Give up...
if( strcmp(name,_name) ) return cnt;
if( !cnt ) strcpy(buf,"_leaf");
if( !cnt ) {
for(int i = 0; i < level; i++) {
int kid = path_bitmask & (1 << i);
if (0 == kid) {
strcpy( buf, "_kids[0]->" );
} else {
strcpy( buf, "_kids[1]->" );
}
buf += 10;
}
strcpy( buf, "_leaf" );
}
return cnt-1;
}
return cnt;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/adlc/formssel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ class MatchNode : public Form {

// Help build instruction predicates. Search for operand names.
void count_instr_names( Dict &names );
int build_instr_pred( char *buf, const char *name, int cnt );
int build_instr_pred( char *buf, const char *name, int cnt, int path_bitmask, int level);
void build_internalop( );

// Return the name of the operands associated with reducing to this operand:
Expand Down

1 comment on commit cddbb15

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.