[all-commits] [llvm/llvm-project] b481cd: Ensure that InstructionCost actually implements a ...
Christopher Tetreault via All-commits
all-commits at lists.llvm.org
Tue Feb 2 11:49:44 PST 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: b481cd519e07b3ad2bd3e81c89b0dd8efd68d6bc
https://github.com/llvm/llvm-project/commit/b481cd519e07b3ad2bd3e81c89b0dd8efd68d6bc
Author: Christopher Tetreault <ctetreau at quicinc.com>
Date: 2021-02-02 (Tue, 02 Feb 2021)
Changed paths:
M llvm/include/llvm/Support/InstructionCost.h
M llvm/unittests/Support/InstructionCostTest.cpp
Log Message:
-----------
Ensure that InstructionCost actually implements a total ordering
Previously, operator== would consider the actual equality of the pairs
(lhs.Value, lhs.State) == (rhs.Value, rhs.State). However, if an invalid
cost was involved in a call to operator<, only the state would be
compared. Thus, it was not the case that ({2, Invalid} < {3, Invalid} ||
{2, Invalid} > {3, Invalid} || {2, Invalid} == {3, Invalid}).
This patch implements a true total ordering, where cost state is
considered first, then value. While it's not really imporant that
{2, Invalid} be considered to be less than {3, Invalid}, it's not a
problem either. This patch also implements operator== in terms of
operator<, so the two definitions will be kept in sync.
Reviewed By: sdesmalen
Differential Revision: https://reviews.llvm.org/D95803
More information about the All-commits
mailing list