Skip to content

Commit e97dceb

Browse files
committed
Rename Cmp -> C
1 parent 349ab90 commit e97dceb

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

llvm/include/llvm/Analysis/CmpInstAnalysis.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,21 @@ namespace llvm {
9292
Constant *getPredForFCmpCode(unsigned Code, Type *OpTy,
9393
CmpInst::Predicate &Pred);
9494

95-
/// Represents the operation icmp (X & Mask) pred Cmp, where pred can only be
95+
/// Represents the operation icmp (X & Mask) pred C, where pred can only be
9696
/// eq or ne.
9797
struct DecomposedBitTest {
9898
Value *X;
9999
CmpInst::Predicate Pred;
100100
APInt Mask;
101-
APInt Cmp;
101+
APInt C;
102102
};
103103

104-
/// Decompose an icmp into the form ((X & Mask) pred Cmp) if possible.
105-
/// Unless \p AllowNonZeroCmp is true, Cmp will always be 0.
104+
/// Decompose an icmp into the form ((X & Mask) pred C) if possible.
105+
/// Unless \p AllowNonZeroC is true, C will always be 0.
106106
std::optional<DecomposedBitTest>
107107
decomposeBitTestICmp(Value *LHS, Value *RHS, CmpInst::Predicate Pred,
108108
bool LookThroughTrunc = true,
109-
bool AllowNonZeroCmp = false);
109+
bool AllowNonZeroC = false);
110110

111111
} // end namespace llvm
112112

llvm/lib/Analysis/CmpInstAnalysis.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Constant *llvm::getPredForFCmpCode(unsigned Code, Type *OpTy,
7575

7676
std::optional<DecomposedBitTest>
7777
llvm::decomposeBitTestICmp(Value *LHS, Value *RHS, CmpInst::Predicate Pred,
78-
bool LookThruTrunc, bool AllowNonZeroCmp) {
78+
bool LookThruTrunc, bool AllowNonZeroC) {
7979
using namespace PatternMatch;
8080

8181
const APInt *OrigC;
@@ -104,7 +104,7 @@ llvm::decomposeBitTestICmp(Value *LHS, Value *RHS, CmpInst::Predicate Pred,
104104
// X < 0 is equivalent to (X & SignMask) != 0.
105105
if (C.isZero()) {
106106
Result.Mask = APInt::getSignMask(C.getBitWidth());
107-
Result.Cmp = APInt::getZero(C.getBitWidth());
107+
Result.C = APInt::getZero(C.getBitWidth());
108108
Result.Pred = ICmpInst::ICMP_NE;
109109
break;
110110
}
@@ -113,15 +113,15 @@ llvm::decomposeBitTestICmp(Value *LHS, Value *RHS, CmpInst::Predicate Pred,
113113
if (FlippedSign.isPowerOf2()) {
114114
// X s< 10000100 is equivalent to (X & 11111100 == 10000000)
115115
Result.Mask = -FlippedSign;
116-
Result.Cmp = APInt::getSignMask(C.getBitWidth());
116+
Result.C = APInt::getSignMask(C.getBitWidth());
117117
Result.Pred = ICmpInst::ICMP_EQ;
118118
break;
119119
}
120120

121121
if (FlippedSign.isNegatedPowerOf2()) {
122122
// X s< 01111100 is equivalent to (X & 11111100 != 01111100)
123123
Result.Mask = FlippedSign;
124-
Result.Cmp = C;
124+
Result.C = C;
125125
Result.Pred = ICmpInst::ICMP_NE;
126126
break;
127127
}
@@ -132,23 +132,23 @@ llvm::decomposeBitTestICmp(Value *LHS, Value *RHS, CmpInst::Predicate Pred,
132132
// X <u 2^n is equivalent to (X & ~(2^n-1)) == 0.
133133
if (C.isPowerOf2()) {
134134
Result.Mask = -C;
135-
Result.Cmp = APInt::getZero(C.getBitWidth());
135+
Result.C = APInt::getZero(C.getBitWidth());
136136
Result.Pred = ICmpInst::ICMP_EQ;
137137
break;
138138
}
139139

140140
// X u< 11111100 is equivalent to (X & 11111100 != 11111100)
141141
if (C.isNegatedPowerOf2()) {
142142
Result.Mask = C;
143-
Result.Cmp = C;
143+
Result.C = C;
144144
Result.Pred = ICmpInst::ICMP_NE;
145145
break;
146146
}
147147

148148
return std::nullopt;
149149
}
150150

151-
if (!AllowNonZeroCmp && !Result.Cmp.isZero())
151+
if (!AllowNonZeroC && !Result.C.isZero())
152152
return std::nullopt;
153153

154154
if (Inverted)
@@ -158,7 +158,7 @@ llvm::decomposeBitTestICmp(Value *LHS, Value *RHS, CmpInst::Predicate Pred,
158158
if (LookThruTrunc && match(LHS, m_Trunc(m_Value(X)))) {
159159
Result.X = X;
160160
Result.Mask = Result.Mask.zext(X->getType()->getScalarSizeInBits());
161-
Result.Cmp = Result.Cmp.zext(X->getType()->getScalarSizeInBits());
161+
Result.C = Result.C.zext(X->getType()->getScalarSizeInBits());
162162
} else {
163163
Result.X = LHS;
164164
}

llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,14 @@ static unsigned conjugateICmpMask(unsigned Mask) {
182182
static bool decomposeBitTestICmp(Value *LHS, Value *RHS, CmpInst::Predicate &Pred,
183183
Value *&X, Value *&Y, Value *&Z) {
184184
auto Res = llvm::decomposeBitTestICmp(
185-
LHS, RHS, Pred, /*LookThroughTrunc=*/true, /*AllowNonZeroCmp=*/true);
185+
LHS, RHS, Pred, /*LookThroughTrunc=*/true, /*AllowNonZeroC=*/true);
186186
if (!Res)
187187
return false;
188188

189189
Pred = Res->Pred;
190190
X = Res->X;
191191
Y = ConstantInt::get(X->getType(), Res->Mask);
192-
Z = ConstantInt::get(X->getType(), Res->Cmp);
192+
Z = ConstantInt::get(X->getType(), Res->C);
193193
return true;
194194
}
195195

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5935,9 +5935,9 @@ Instruction *InstCombinerImpl::foldICmpWithTrunc(ICmpInst &ICmp) {
59355935
// (trunc X) u< C --> (X & -C) == 0 (are all masked-high-bits clear?)
59365936
// (trunc X) u> C --> (X & ~C) != 0 (are any masked-high-bits set?)
59375937
if (auto Res = decomposeBitTestICmp(Op0, Op1, Pred, /*WithTrunc=*/true,
5938-
/*AllowNonZeroCmp=*/true)) {
5938+
/*AllowNonZeroC=*/true)) {
59395939
Value *And = Builder.CreateAnd(Res->X, Res->Mask);
5940-
Constant *Zero = ConstantInt::get(Res->X->getType(), Res->Cmp);
5940+
Constant *Zero = ConstantInt::get(Res->X->getType(), Res->C);
59415941
return new ICmpInst(Res->Pred, And, Zero);
59425942
}
59435943

0 commit comments

Comments
 (0)