Skip to content
Permalink
Browse files
8259777: Incorrect predication condition generated by ADLC
Reviewed-by: vlivanov, kvn
Backport-of: bcf20a0dcc752707881d3b4da25712d3ef4e93ff
  • Loading branch information
TobiHartmann committed Feb 2, 2021
1 parent f8af3b5 commit cddbb158b50cdfc315f703fc6b28a74ee4816ced
Showing with 26 additions and 11 deletions.
  1. +25 −10 src/hotspot/share/adlc/formssel.cpp
  2. +1 −1 src/hotspot/share/adlc/formssel.hpp
@@ -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;
@@ -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);
}
@@ -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;
@@ -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:

1 comment on commit cddbb15

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on cddbb15 Feb 2, 2021

Please sign in to comment.