Skip to content

Commit c3e72a2

Browse files
committed
[IR] Remove support for icmp and fcmp constant expressions
Remove support for the icmp and fcmp constant expressions. This is part of: https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179
1 parent 2f1229e commit c3e72a2

File tree

116 files changed

+355
-735
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+355
-735
lines changed

llvm/bindings/ocaml/llvm/llvm.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -651,10 +651,6 @@ external const_mul : llvalue -> llvalue -> llvalue = "llvm_const_mul"
651651
external const_nsw_mul : llvalue -> llvalue -> llvalue = "llvm_const_nsw_mul"
652652
external const_nuw_mul : llvalue -> llvalue -> llvalue = "llvm_const_nuw_mul"
653653
external const_xor : llvalue -> llvalue -> llvalue = "llvm_const_xor"
654-
external const_icmp : Icmp.t -> llvalue -> llvalue -> llvalue
655-
= "llvm_const_icmp"
656-
external const_fcmp : Fcmp.t -> llvalue -> llvalue -> llvalue
657-
= "llvm_const_fcmp"
658654
external const_shl : llvalue -> llvalue -> llvalue = "llvm_const_shl"
659655
external const_gep : lltype -> llvalue -> llvalue array -> llvalue
660656
= "llvm_const_gep"

llvm/bindings/ocaml/llvm/llvm.mli

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,16 +1136,6 @@ val const_nuw_mul : llvalue -> llvalue -> llvalue
11361136
See the method [llvm::ConstantExpr::getXor]. *)
11371137
val const_xor : llvalue -> llvalue -> llvalue
11381138

1139-
(** [const_icmp pred c1 c2] returns the constant comparison of two integer
1140-
constants, [c1 pred c2].
1141-
See the method [llvm::ConstantExpr::getICmp]. *)
1142-
val const_icmp : Icmp.t -> llvalue -> llvalue -> llvalue
1143-
1144-
(** [const_fcmp pred c1 c2] returns the constant comparison of two floating
1145-
point constants, [c1 pred c2].
1146-
See the method [llvm::ConstantExpr::getFCmp]. *)
1147-
val const_fcmp : Fcmp.t -> llvalue -> llvalue -> llvalue
1148-
11491139
(** [const_shl c1 c2] returns the constant integer [c1] left-shifted by the
11501140
constant integer [c2].
11511141
See the method [llvm::ConstantExpr::getShl]. *)

llvm/bindings/ocaml/llvm/llvm_ocaml.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,18 +1224,6 @@ value llvm_const_xor(value LHS, value RHS) {
12241224
return to_val(Value);
12251225
}
12261226

1227-
/* Icmp.t -> llvalue -> llvalue -> llvalue */
1228-
value llvm_const_icmp(value Pred, value LHSConstant, value RHSConstant) {
1229-
return to_val(LLVMConstICmp(Int_val(Pred) + LLVMIntEQ, Value_val(LHSConstant),
1230-
Value_val(RHSConstant)));
1231-
}
1232-
1233-
/* Fcmp.t -> llvalue -> llvalue -> llvalue */
1234-
value llvm_const_fcmp(value Pred, value LHSConstant, value RHSConstant) {
1235-
return to_val(LLVMConstFCmp(Int_val(Pred), Value_val(LHSConstant),
1236-
Value_val(RHSConstant)));
1237-
}
1238-
12391227
/* llvalue -> llvalue -> llvalue */
12401228
value llvm_const_shl(value LHS, value RHS) {
12411229
LLVMValueRef Value = LLVMConstShl(Value_val(LHS), Value_val(RHS));

llvm/docs/LangRef.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4821,10 +4821,6 @@ The following is the syntax for constant expressions:
48214821
required to make sense for the type of "pointer to TY". These indexes
48224822
may be implicitly sign-extended or truncated to match the index size
48234823
of CSTPTR's address space.
4824-
``icmp COND (VAL1, VAL2)``
4825-
Perform the :ref:`icmp operation <i_icmp>` on constants.
4826-
``fcmp COND (VAL1, VAL2)``
4827-
Perform the :ref:`fcmp operation <i_fcmp>` on constants.
48284824
``extractelement (VAL, IDX)``
48294825
Perform the :ref:`extractelement operation <i_extractelement>` on
48304826
constants.

llvm/docs/ReleaseNotes.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ Changes to the LLVM IR
5656
* Renamed ``llvm.experimental.vector.splice`` intrinsic to ``llvm.vector.splice``.
5757
* Renamed ``llvm.experimental.vector.interleave2`` intrinsic to ``llvm.vector.interleave2``.
5858
* Renamed ``llvm.experimental.vector.deinterleave2`` intrinsic to ``llvm.vector.deinterleave2``.
59+
* The constant expression variants of the following instructions have been
60+
removed:
61+
62+
* ``icmp``
63+
* ``fcmp``
5964

6065
Changes to LLVM infrastructure
6166
------------------------------
@@ -191,6 +196,14 @@ Changes to the C API
191196
* ``LLVMGetCallBrNumIndirectDests``
192197
* ``LLVMGetCallBrIndirectDest``
193198

199+
* The following functions for creating constant expressions have been removed,
200+
because the underlying constant expressions are no longer supported. Instead,
201+
an instruction should be created using the ``LLVMBuildXYZ`` APIs, which will
202+
constant fold the operands if possible and create an instruction otherwise:
203+
204+
* ``LLVMConstICmp``
205+
* ``LLVMConstFCmp``
206+
194207
Changes to the CodeGen infrastructure
195208
-------------------------------------
196209

llvm/include/llvm-c/Core.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,10 +2354,6 @@ LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
23542354
LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
23552355
LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
23562356
LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2357-
LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
2358-
LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2359-
LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
2360-
LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
23612357
LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
23622358
LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
23632359
LLVMValueRef *ConstantIndices, unsigned NumIndices);

llvm/include/llvm/IR/Constants.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,30 +1234,13 @@ class ConstantExpr : public Constant {
12341234
/// Return true if this is a convert constant expression
12351235
bool isCast() const;
12361236

1237-
/// Return true if this is a compare constant expression
1238-
bool isCompare() const;
1239-
12401237
/// get - Return a binary or shift operator constant expression,
12411238
/// folding if possible.
12421239
///
12431240
/// \param OnlyIfReducedTy see \a getWithOperands() docs.
12441241
static Constant *get(unsigned Opcode, Constant *C1, Constant *C2,
12451242
unsigned Flags = 0, Type *OnlyIfReducedTy = nullptr);
12461243

1247-
/// Return an ICmp or FCmp comparison operator constant expression.
1248-
///
1249-
/// \param OnlyIfReduced see \a getWithOperands() docs.
1250-
static Constant *getCompare(unsigned short pred, Constant *C1, Constant *C2,
1251-
bool OnlyIfReduced = false);
1252-
1253-
/// get* - Return some common constants without having to
1254-
/// specify the full Instruction::OPCODE identifier.
1255-
///
1256-
static Constant *getICmp(unsigned short pred, Constant *LHS, Constant *RHS,
1257-
bool OnlyIfReduced = false);
1258-
static Constant *getFCmp(unsigned short pred, Constant *LHS, Constant *RHS,
1259-
bool OnlyIfReduced = false);
1260-
12611244
/// Getelementptr form. Value* is only accepted for convenience;
12621245
/// all elements must be Constants.
12631246
///
@@ -1318,10 +1301,6 @@ class ConstantExpr : public Constant {
13181301
/// Return the opcode at the root of this constant expression
13191302
unsigned getOpcode() const { return getSubclassDataFromValue(); }
13201303

1321-
/// Return the ICMP or FCMP predicate value. Assert if this is not an ICMP or
1322-
/// FCMP constant expression.
1323-
unsigned getPredicate() const;
1324-
13251304
/// Assert that this is a shufflevector and return the mask. See class
13261305
/// ShuffleVectorInst for a description of the mask representation.
13271306
ArrayRef<int> getShuffleMask() const;

llvm/lib/Analysis/ConstantFolding.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,12 +1009,8 @@ Constant *ConstantFoldInstOperandsImpl(const Value *InstOrCE, unsigned Opcode,
10091009
GEP->getInRange());
10101010
}
10111011

1012-
if (auto *CE = dyn_cast<ConstantExpr>(InstOrCE)) {
1013-
if (CE->isCompare())
1014-
return ConstantFoldCompareInstOperands(CE->getPredicate(), Ops[0], Ops[1],
1015-
DL, TLI);
1012+
if (auto *CE = dyn_cast<ConstantExpr>(InstOrCE))
10161013
return CE->getWithOperands(Ops);
1017-
}
10181014

10191015
switch (Opcode) {
10201016
default: return nullptr;

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4176,37 +4176,9 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
41764176
case lltok::kw_fptosi:
41774177
return error(ID.Loc, "fptosi constexprs are no longer supported");
41784178
case lltok::kw_icmp:
4179-
case lltok::kw_fcmp: {
4180-
unsigned PredVal, Opc = Lex.getUIntVal();
4181-
Constant *Val0, *Val1;
4182-
Lex.Lex();
4183-
if (parseCmpPredicate(PredVal, Opc) ||
4184-
parseToken(lltok::lparen, "expected '(' in compare constantexpr") ||
4185-
parseGlobalTypeAndValue(Val0) ||
4186-
parseToken(lltok::comma, "expected comma in compare constantexpr") ||
4187-
parseGlobalTypeAndValue(Val1) ||
4188-
parseToken(lltok::rparen, "expected ')' in compare constantexpr"))
4189-
return true;
4190-
4191-
if (Val0->getType() != Val1->getType())
4192-
return error(ID.Loc, "compare operands must have the same type");
4193-
4194-
CmpInst::Predicate Pred = (CmpInst::Predicate)PredVal;
4195-
4196-
if (Opc == Instruction::FCmp) {
4197-
if (!Val0->getType()->isFPOrFPVectorTy())
4198-
return error(ID.Loc, "fcmp requires floating point operands");
4199-
ID.ConstantVal = ConstantExpr::getFCmp(Pred, Val0, Val1);
4200-
} else {
4201-
assert(Opc == Instruction::ICmp && "Unexpected opcode for CmpInst!");
4202-
if (!Val0->getType()->isIntOrIntVectorTy() &&
4203-
!Val0->getType()->isPtrOrPtrVectorTy())
4204-
return error(ID.Loc, "icmp requires pointer or integer operands");
4205-
ID.ConstantVal = ConstantExpr::getICmp(Pred, Val0, Val1);
4206-
}
4207-
ID.Kind = ValID::t_Constant;
4208-
return false;
4209-
}
4179+
return error(ID.Loc, "icmp constexprs are no longer supported");
4180+
case lltok::kw_fcmp:
4181+
return error(ID.Loc, "fcmp constexprs are no longer supported");
42104182

42114183
// Binary Operators.
42124184
case lltok::kw_add:

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,6 +1495,8 @@ static bool isConstExprSupported(const BitcodeConstant *BC) {
14951495
switch (Opcode) {
14961496
case Instruction::FNeg:
14971497
case Instruction::Select:
1498+
case Instruction::ICmp:
1499+
case Instruction::FCmp:
14981500
return false;
14991501
default:
15001502
return true;
@@ -1633,10 +1635,6 @@ Expected<Value *> BitcodeReader::materializeValue(unsigned StartValID,
16331635
case BitcodeConstant::ConstantVectorOpcode:
16341636
C = ConstantVector::get(ConstOps);
16351637
break;
1636-
case Instruction::ICmp:
1637-
case Instruction::FCmp:
1638-
C = ConstantExpr::getCompare(BC->Flags, ConstOps[0], ConstOps[1]);
1639-
break;
16401638
case Instruction::GetElementPtr:
16411639
C = ConstantExpr::getGetElementPtr(
16421640
BC->SrcElemTy, ConstOps[0], ArrayRef(ConstOps).drop_front(),

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,14 +2822,6 @@ void ModuleBitcodeWriter::writeConstants(unsigned FirstVal, unsigned LastVal,
28222822
Record.push_back(VE.getValueID(C->getOperand(1)));
28232823
Record.push_back(VE.getValueID(CE->getShuffleMaskForBitcode()));
28242824
break;
2825-
case Instruction::ICmp:
2826-
case Instruction::FCmp:
2827-
Code = bitc::CST_CODE_CE_CMP;
2828-
Record.push_back(VE.getTypeID(C->getOperand(0)->getType()));
2829-
Record.push_back(VE.getValueID(C->getOperand(0)));
2830-
Record.push_back(VE.getValueID(C->getOperand(1)));
2831-
Record.push_back(CE->getPredicate());
2832-
break;
28332825
}
28342826
} else if (const BlockAddress *BA = dyn_cast<BlockAddress>(C)) {
28352827
Code = bitc::CST_CODE_BLOCKADDRESS;

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,11 @@ bool IRTranslator::translateFNeg(const User &U, MachineIRBuilder &MIRBuilder) {
335335

336336
bool IRTranslator::translateCompare(const User &U,
337337
MachineIRBuilder &MIRBuilder) {
338-
auto *CI = dyn_cast<CmpInst>(&U);
338+
auto *CI = cast<CmpInst>(&U);
339339
Register Op0 = getOrCreateVReg(*U.getOperand(0));
340340
Register Op1 = getOrCreateVReg(*U.getOperand(1));
341341
Register Res = getOrCreateVReg(U);
342-
CmpInst::Predicate Pred =
343-
CI ? CI->getPredicate() : static_cast<CmpInst::Predicate>(
344-
cast<ConstantExpr>(U).getPredicate());
342+
CmpInst::Predicate Pred = CI->getPredicate();
345343
if (CmpInst::isIntPredicate(Pred))
346344
MIRBuilder.buildICmp(Pred, Res, Op0, Op1);
347345
else if (Pred == CmpInst::FCMP_FALSE)

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3617,12 +3617,8 @@ void SelectionDAGBuilder::visitSDiv(const User &I) {
36173617
Op2, Flags));
36183618
}
36193619

3620-
void SelectionDAGBuilder::visitICmp(const User &I) {
3621-
ICmpInst::Predicate predicate = ICmpInst::BAD_ICMP_PREDICATE;
3622-
if (const ICmpInst *IC = dyn_cast<ICmpInst>(&I))
3623-
predicate = IC->getPredicate();
3624-
else if (const ConstantExpr *IC = dyn_cast<ConstantExpr>(&I))
3625-
predicate = ICmpInst::Predicate(IC->getPredicate());
3620+
void SelectionDAGBuilder::visitICmp(const ICmpInst &I) {
3621+
ICmpInst::Predicate predicate = I.getPredicate();
36263622
SDValue Op1 = getValue(I.getOperand(0));
36273623
SDValue Op2 = getValue(I.getOperand(1));
36283624
ISD::CondCode Opcode = getICmpCondCode(predicate);
@@ -3644,12 +3640,8 @@ void SelectionDAGBuilder::visitICmp(const User &I) {
36443640
setValue(&I, DAG.getSetCC(getCurSDLoc(), DestVT, Op1, Op2, Opcode));
36453641
}
36463642

3647-
void SelectionDAGBuilder::visitFCmp(const User &I) {
3648-
FCmpInst::Predicate predicate = FCmpInst::BAD_FCMP_PREDICATE;
3649-
if (const FCmpInst *FC = dyn_cast<FCmpInst>(&I))
3650-
predicate = FC->getPredicate();
3651-
else if (const ConstantExpr *FC = dyn_cast<ConstantExpr>(&I))
3652-
predicate = FCmpInst::Predicate(FC->getPredicate());
3643+
void SelectionDAGBuilder::visitFCmp(const FCmpInst &I) {
3644+
FCmpInst::Predicate predicate = I.getPredicate();
36533645
SDValue Op1 = getValue(I.getOperand(0));
36543646
SDValue Op2 = getValue(I.getOperand(1));
36553647

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,8 @@ class SelectionDAGBuilder {
563563
void visitShl (const User &I) { visitShift(I, ISD::SHL); }
564564
void visitLShr(const User &I) { visitShift(I, ISD::SRL); }
565565
void visitAShr(const User &I) { visitShift(I, ISD::SRA); }
566-
void visitICmp(const User &I);
567-
void visitFCmp(const User &I);
566+
void visitICmp(const ICmpInst &I);
567+
void visitFCmp(const FCmpInst &I);
568568
// Visit the conversion instructions
569569
void visitTrunc(const User &I);
570570
void visitZExt(const User &I);

llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -697,42 +697,6 @@ void Interpreter::visitFCmpInst(FCmpInst &I) {
697697
SetValue(&I, R, SF);
698698
}
699699

700-
static GenericValue executeCmpInst(unsigned predicate, GenericValue Src1,
701-
GenericValue Src2, Type *Ty) {
702-
GenericValue Result;
703-
switch (predicate) {
704-
case ICmpInst::ICMP_EQ: return executeICMP_EQ(Src1, Src2, Ty);
705-
case ICmpInst::ICMP_NE: return executeICMP_NE(Src1, Src2, Ty);
706-
case ICmpInst::ICMP_UGT: return executeICMP_UGT(Src1, Src2, Ty);
707-
case ICmpInst::ICMP_SGT: return executeICMP_SGT(Src1, Src2, Ty);
708-
case ICmpInst::ICMP_ULT: return executeICMP_ULT(Src1, Src2, Ty);
709-
case ICmpInst::ICMP_SLT: return executeICMP_SLT(Src1, Src2, Ty);
710-
case ICmpInst::ICMP_UGE: return executeICMP_UGE(Src1, Src2, Ty);
711-
case ICmpInst::ICMP_SGE: return executeICMP_SGE(Src1, Src2, Ty);
712-
case ICmpInst::ICMP_ULE: return executeICMP_ULE(Src1, Src2, Ty);
713-
case ICmpInst::ICMP_SLE: return executeICMP_SLE(Src1, Src2, Ty);
714-
case FCmpInst::FCMP_ORD: return executeFCMP_ORD(Src1, Src2, Ty);
715-
case FCmpInst::FCMP_UNO: return executeFCMP_UNO(Src1, Src2, Ty);
716-
case FCmpInst::FCMP_OEQ: return executeFCMP_OEQ(Src1, Src2, Ty);
717-
case FCmpInst::FCMP_UEQ: return executeFCMP_UEQ(Src1, Src2, Ty);
718-
case FCmpInst::FCMP_ONE: return executeFCMP_ONE(Src1, Src2, Ty);
719-
case FCmpInst::FCMP_UNE: return executeFCMP_UNE(Src1, Src2, Ty);
720-
case FCmpInst::FCMP_OLT: return executeFCMP_OLT(Src1, Src2, Ty);
721-
case FCmpInst::FCMP_ULT: return executeFCMP_ULT(Src1, Src2, Ty);
722-
case FCmpInst::FCMP_OGT: return executeFCMP_OGT(Src1, Src2, Ty);
723-
case FCmpInst::FCMP_UGT: return executeFCMP_UGT(Src1, Src2, Ty);
724-
case FCmpInst::FCMP_OLE: return executeFCMP_OLE(Src1, Src2, Ty);
725-
case FCmpInst::FCMP_ULE: return executeFCMP_ULE(Src1, Src2, Ty);
726-
case FCmpInst::FCMP_OGE: return executeFCMP_OGE(Src1, Src2, Ty);
727-
case FCmpInst::FCMP_UGE: return executeFCMP_UGE(Src1, Src2, Ty);
728-
case FCmpInst::FCMP_FALSE: return executeFCMP_BOOL(Src1, Src2, Ty, false);
729-
case FCmpInst::FCMP_TRUE: return executeFCMP_BOOL(Src1, Src2, Ty, true);
730-
default:
731-
dbgs() << "Unhandled Cmp predicate\n";
732-
llvm_unreachable(nullptr);
733-
}
734-
}
735-
736700
void Interpreter::visitBinaryOperator(BinaryOperator &I) {
737701
ExecutionContext &SF = ECStack.back();
738702
Type *Ty = I.getOperand(0)->getType();
@@ -2028,13 +1992,6 @@ GenericValue Interpreter::getConstantExprValue (ConstantExpr *CE,
20281992
case Instruction::GetElementPtr:
20291993
return executeGEPOperation(CE->getOperand(0), gep_type_begin(CE),
20301994
gep_type_end(CE), SF);
2031-
case Instruction::FCmp:
2032-
case Instruction::ICmp:
2033-
return executeCmpInst(CE->getPredicate(),
2034-
getOperandValue(CE->getOperand(0), SF),
2035-
getOperandValue(CE->getOperand(1), SF),
2036-
CE->getOperand(0)->getType());
2037-
default:
20381995
break;
20391996
}
20401997

llvm/lib/IR/AsmWriter.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,8 +1724,6 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV,
17241724
if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
17251725
Out << CE->getOpcodeName();
17261726
WriteOptimizationInfo(Out, CE);
1727-
if (CE->isCompare())
1728-
Out << ' ' << static_cast<CmpInst::Predicate>(CE->getPredicate());
17291727
Out << " (";
17301728

17311729
if (const GEPOperator *GEP = dyn_cast<GEPOperator>(CE)) {

llvm/lib/IR/ConstantFold.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -863,22 +863,6 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
863863
if (CI2->isMinusOne())
864864
return C2; // X | -1 == -1
865865
break;
866-
case Instruction::Xor:
867-
if (ConstantExpr *CE1 = dyn_cast<ConstantExpr>(C1)) {
868-
switch (CE1->getOpcode()) {
869-
default:
870-
break;
871-
case Instruction::ICmp:
872-
case Instruction::FCmp:
873-
// cmp pred ^ true -> cmp !pred
874-
assert(CI2->isOne());
875-
CmpInst::Predicate pred = (CmpInst::Predicate)CE1->getPredicate();
876-
pred = CmpInst::getInversePredicate(pred);
877-
return ConstantExpr::getCompare(pred, CE1->getOperand(0),
878-
CE1->getOperand(1));
879-
}
880-
}
881-
break;
882866
}
883867
} else if (isa<ConstantInt>(C1)) {
884868
// If C1 is a ConstantInt and C2 is not, swap the operands.

0 commit comments

Comments
 (0)