File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
llvm/lib/Transforms/Scalar Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -4128,21 +4128,25 @@ bool NewGVN::eliminateInstructions(Function &F) {
4128
4128
unsigned int NewGVN::getRank (const Value *V) const {
4129
4129
// Prefer constants to undef to anything else
4130
4130
// Undef is a constant, have to check it first.
4131
+ // Prefer poison to undef as it's less defined.
4131
4132
// Prefer smaller constants to constantexprs
4133
+ // Note that the order here matters because of class inheritance
4132
4134
if (isa<ConstantExpr>(V))
4133
- return 2 ;
4134
- if (isa<UndefValue >(V))
4135
+ return 3 ;
4136
+ if (isa<PoisonValue >(V))
4135
4137
return 1 ;
4138
+ if (isa<UndefValue>(V))
4139
+ return 2 ;
4136
4140
if (isa<Constant>(V))
4137
4141
return 0 ;
4138
- else if (auto *A = dyn_cast<Argument>(V))
4139
- return 3 + A->getArgNo ();
4142
+ if (auto *A = dyn_cast<Argument>(V))
4143
+ return 4 + A->getArgNo ();
4140
4144
4141
- // Need to shift the instruction DFS by number of arguments + 3 to account for
4145
+ // Need to shift the instruction DFS by number of arguments + 5 to account for
4142
4146
// the constant and argument ranking above.
4143
4147
unsigned Result = InstrToDFSNum (V);
4144
4148
if (Result > 0 )
4145
- return 4 + NumFuncArgs + Result;
4149
+ return 5 + NumFuncArgs + Result;
4146
4150
// Unreachable or something else, just return a really large number.
4147
4151
return ~0 ;
4148
4152
}
You can’t perform that action at this time.
0 commit comments