Skip to content

Commit 8c38fc5

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 0748a98 commit 8c38fc5

File tree

65 files changed

+194
-523
lines changed

Some content is hidden

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

65 files changed

+194
-523
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
@@ -4787,10 +4787,6 @@ The following is the syntax for constant expressions:
47874787
required to make sense for the type of "pointer to TY". These indexes
47884788
may be implicitly sign-extended or truncated to match the index size
47894789
of CSTPTR's address space.
4790-
``icmp COND (VAL1, VAL2)``
4791-
Perform the :ref:`icmp operation <i_icmp>` on constants.
4792-
``fcmp COND (VAL1, VAL2)``
4793-
Perform the :ref:`fcmp operation <i_fcmp>` on constants.
47944790
``extractelement (VAL, IDX)``
47954791
Perform the :ref:`extractelement operation <i_extractelement>` on
47964792
constants.

llvm/docs/ReleaseNotes.rst

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

5964
Changes to LLVM infrastructure
6065
------------------------------
@@ -181,6 +186,14 @@ Changes to the C API
181186
* ``LLVMGetCallBrNumIndirectDests``
182187
* ``LLVMGetCallBrIndirectDest``
183188

189+
* The following functions for creating constant expressions have been removed,
190+
because the underlying constant expressions are no longer supported. Instead,
191+
an instruction should be created using the ``LLVMBuildXYZ`` APIs, which will
192+
constant fold the operands if possible and create an instruction otherwise:
193+
194+
* ``LLVMConstICmp``
195+
* ``LLVMConstFCmp``
196+
184197
Changes to the CodeGen infrastructure
185198
-------------------------------------
186199

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
@@ -1167,30 +1167,13 @@ class ConstantExpr : public Constant {
11671167
/// Return true if this is a convert constant expression
11681168
bool isCast() const;
11691169

1170-
/// Return true if this is a compare constant expression
1171-
bool isCompare() const;
1172-
11731170
/// get - Return a binary or shift operator constant expression,
11741171
/// folding if possible.
11751172
///
11761173
/// \param OnlyIfReducedTy see \a getWithOperands() docs.
11771174
static Constant *get(unsigned Opcode, Constant *C1, Constant *C2,
11781175
unsigned Flags = 0, Type *OnlyIfReducedTy = nullptr);
11791176

1180-
/// Return an ICmp or FCmp comparison operator constant expression.
1181-
///
1182-
/// \param OnlyIfReduced see \a getWithOperands() docs.
1183-
static Constant *getCompare(unsigned short pred, Constant *C1, Constant *C2,
1184-
bool OnlyIfReduced = false);
1185-
1186-
/// get* - Return some common constants without having to
1187-
/// specify the full Instruction::OPCODE identifier.
1188-
///
1189-
static Constant *getICmp(unsigned short pred, Constant *LHS, Constant *RHS,
1190-
bool OnlyIfReduced = false);
1191-
static Constant *getFCmp(unsigned short pred, Constant *LHS, Constant *RHS,
1192-
bool OnlyIfReduced = false);
1193-
11941177
/// Getelementptr form. Value* is only accepted for convenience;
11951178
/// all elements must be Constants.
11961179
///
@@ -1250,10 +1233,6 @@ class ConstantExpr : public Constant {
12501233
/// Return the opcode at the root of this constant expression
12511234
unsigned getOpcode() const { return getSubclassDataFromValue(); }
12521235

1253-
/// Return the ICMP or FCMP predicate value. Assert if this is not an ICMP or
1254-
/// FCMP constant expression.
1255-
unsigned getPredicate() const;
1256-
12571236
/// Assert that this is a shufflevector and return the mask. See class
12581237
/// ShuffleVectorInst for a description of the mask representation.
12591238
ArrayRef<int> getShuffleMask() const;

llvm/lib/Analysis/ConstantFolding.cpp

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

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

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

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4122,37 +4122,9 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
41224122
case lltok::kw_fptosi:
41234123
return error(ID.Loc, "fptosi constexprs are no longer supported");
41244124
case lltok::kw_icmp:
4125-
case lltok::kw_fcmp: {
4126-
unsigned PredVal, Opc = Lex.getUIntVal();
4127-
Constant *Val0, *Val1;
4128-
Lex.Lex();
4129-
if (parseCmpPredicate(PredVal, Opc) ||
4130-
parseToken(lltok::lparen, "expected '(' in compare constantexpr") ||
4131-
parseGlobalTypeAndValue(Val0) ||
4132-
parseToken(lltok::comma, "expected comma in compare constantexpr") ||
4133-
parseGlobalTypeAndValue(Val1) ||
4134-
parseToken(lltok::rparen, "expected ')' in compare constantexpr"))
4135-
return true;
4136-
4137-
if (Val0->getType() != Val1->getType())
4138-
return error(ID.Loc, "compare operands must have the same type");
4139-
4140-
CmpInst::Predicate Pred = (CmpInst::Predicate)PredVal;
4141-
4142-
if (Opc == Instruction::FCmp) {
4143-
if (!Val0->getType()->isFPOrFPVectorTy())
4144-
return error(ID.Loc, "fcmp requires floating point operands");
4145-
ID.ConstantVal = ConstantExpr::getFCmp(Pred, Val0, Val1);
4146-
} else {
4147-
assert(Opc == Instruction::ICmp && "Unexpected opcode for CmpInst!");
4148-
if (!Val0->getType()->isIntOrIntVectorTy() &&
4149-
!Val0->getType()->isPtrOrPtrVectorTy())
4150-
return error(ID.Loc, "icmp requires pointer or integer operands");
4151-
ID.ConstantVal = ConstantExpr::getICmp(Pred, Val0, Val1);
4152-
}
4153-
ID.Kind = ValID::t_Constant;
4154-
return false;
4155-
}
4125+
return error(ID.Loc, "icmp constexprs are no longer supported");
4126+
case lltok::kw_fcmp:
4127+
return error(ID.Loc, "fcmp constexprs are no longer supported");
41564128

41574129
// Binary Operators.
41584130
case lltok::kw_add:

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,8 @@ static bool isConstExprSupported(const BitcodeConstant *BC) {
14831483
switch (Opcode) {
14841484
case Instruction::FNeg:
14851485
case Instruction::Select:
1486+
case Instruction::ICmp:
1487+
case Instruction::FCmp:
14861488
return false;
14871489
default:
14881490
return true;
@@ -1609,10 +1611,6 @@ Expected<Value *> BitcodeReader::materializeValue(unsigned StartValID,
16091611
case BitcodeConstant::ConstantVectorOpcode:
16101612
C = ConstantVector::get(ConstOps);
16111613
break;
1612-
case Instruction::ICmp:
1613-
case Instruction::FCmp:
1614-
C = ConstantExpr::getCompare(BC->Flags, ConstOps[0], ConstOps[1]);
1615-
break;
16161614
case Instruction::GetElementPtr:
16171615
C = ConstantExpr::getGetElementPtr(BC->SrcElemTy, ConstOps[0],
16181616
ArrayRef(ConstOps).drop_front(),

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2808,14 +2808,6 @@ void ModuleBitcodeWriter::writeConstants(unsigned FirstVal, unsigned LastVal,
28082808
Record.push_back(VE.getValueID(C->getOperand(1)));
28092809
Record.push_back(VE.getValueID(CE->getShuffleMaskForBitcode()));
28102810
break;
2811-
case Instruction::ICmp:
2812-
case Instruction::FCmp:
2813-
Code = bitc::CST_CODE_CE_CMP;
2814-
Record.push_back(VE.getTypeID(C->getOperand(0)->getType()));
2815-
Record.push_back(VE.getValueID(C->getOperand(0)));
2816-
Record.push_back(VE.getValueID(C->getOperand(1)));
2817-
Record.push_back(CE->getPredicate());
2818-
break;
28192811
}
28202812
} else if (const BlockAddress *BA = dyn_cast<BlockAddress>(C)) {
28212813
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
@@ -3615,12 +3615,8 @@ void SelectionDAGBuilder::visitSDiv(const User &I) {
36153615
Op2, Flags));
36163616
}
36173617

3618-
void SelectionDAGBuilder::visitICmp(const User &I) {
3619-
ICmpInst::Predicate predicate = ICmpInst::BAD_ICMP_PREDICATE;
3620-
if (const ICmpInst *IC = dyn_cast<ICmpInst>(&I))
3621-
predicate = IC->getPredicate();
3622-
else if (const ConstantExpr *IC = dyn_cast<ConstantExpr>(&I))
3623-
predicate = ICmpInst::Predicate(IC->getPredicate());
3618+
void SelectionDAGBuilder::visitICmp(const ICmpInst &I) {
3619+
ICmpInst::Predicate predicate = I.getPredicate();
36243620
SDValue Op1 = getValue(I.getOperand(0));
36253621
SDValue Op2 = getValue(I.getOperand(1));
36263622
ISD::CondCode Opcode = getICmpCondCode(predicate);
@@ -3642,12 +3638,8 @@ void SelectionDAGBuilder::visitICmp(const User &I) {
36423638
setValue(&I, DAG.getSetCC(getCurSDLoc(), DestVT, Op1, Op2, Opcode));
36433639
}
36443640

3645-
void SelectionDAGBuilder::visitFCmp(const User &I) {
3646-
FCmpInst::Predicate predicate = FCmpInst::BAD_FCMP_PREDICATE;
3647-
if (const FCmpInst *FC = dyn_cast<FCmpInst>(&I))
3648-
predicate = FC->getPredicate();
3649-
else if (const ConstantExpr *FC = dyn_cast<ConstantExpr>(&I))
3650-
predicate = FCmpInst::Predicate(FC->getPredicate());
3641+
void SelectionDAGBuilder::visitFCmp(const FCmpInst &I) {
3642+
FCmpInst::Predicate predicate = I.getPredicate();
36513643
SDValue Op1 = getValue(I.getOperand(0));
36523644
SDValue Op2 = getValue(I.getOperand(1));
36533645

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h

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

llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

Lines changed: 0 additions & 42 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();
@@ -2044,12 +2008,6 @@ GenericValue Interpreter::getConstantExprValue (ConstantExpr *CE,
20442008
case Instruction::GetElementPtr:
20452009
return executeGEPOperation(CE->getOperand(0), gep_type_begin(CE),
20462010
gep_type_end(CE), SF);
2047-
case Instruction::FCmp:
2048-
case Instruction::ICmp:
2049-
return executeCmpInst(CE->getPredicate(),
2050-
getOperandValue(CE->getOperand(0), SF),
2051-
getOperandValue(CE->getOperand(1), SF),
2052-
CE->getOperand(0)->getType());
20532011
case Instruction::Select:
20542012
return executeSelectInst(getOperandValue(CE->getOperand(0), SF),
20552013
getOperandValue(CE->getOperand(1), SF),

llvm/lib/IR/AsmWriter.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,8 +1699,6 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV,
16991699
if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
17001700
Out << CE->getOpcodeName();
17011701
WriteOptimizationInfo(Out, CE);
1702-
if (CE->isCompare())
1703-
Out << ' ' << static_cast<CmpInst::Predicate>(CE->getPredicate());
17041702
Out << " (";
17051703

17061704
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)