
This patch adds a new undef lattice state, which is used to represent UndefValue constants or instructions producing undef. The main difference to the unknown state is that merging undef values with constants (or single element constant ranges) produces the constant/constant range, assuming all uses of the merge result will be replaced by the found constant. Contrary, merging non-single element ranges with undef needs to go to overdefined. Using unknown for UndefValues currently causes mis-compiles in CVP/LVI (PR44949) and will become problematic once we use ValueLatticeElement for SCCP. Reviewers: efriedma, reames, davide, nikic Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D75120
28 lines
1003 B
C++
28 lines
1003 B
C++
//===- ValueLattice.cpp - Value constraint analysis -------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/Analysis/ValueLattice.h"
|
|
|
|
namespace llvm {
|
|
raw_ostream &operator<<(raw_ostream &OS, const ValueLatticeElement &Val) {
|
|
if (Val.isUnknown())
|
|
return OS << "unknown";
|
|
if (Val.isUndef())
|
|
return OS << "undef";
|
|
if (Val.isOverdefined())
|
|
return OS << "overdefined";
|
|
|
|
if (Val.isNotConstant())
|
|
return OS << "notconstant<" << *Val.getNotConstant() << ">";
|
|
if (Val.isConstantRange())
|
|
return OS << "constantrange<" << Val.getConstantRange().getLower() << ", "
|
|
<< Val.getConstantRange().getUpper() << ">";
|
|
return OS << "constant<" << *Val.getConstant() << ">";
|
|
}
|
|
} // end namespace llvm
|