Skip to content

Commit 4b02877

Browse files
author
Thorsten Schütt
authored
Revert "[GlobalISel] Import samesign flag" (#114256)
Reverts #113090
1 parent eac2c18 commit 4b02877

File tree

12 files changed

+11
-144
lines changed

12 files changed

+11
-144
lines changed

llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace llvm {
2828
class GenericMachineInstr : public MachineInstr {
2929
constexpr static unsigned PoisonFlags = NoUWrap | NoSWrap | NoUSWrap |
3030
IsExact | Disjoint | NonNeg |
31-
FmNoNans | FmNoInfs | SameSign;
31+
FmNoNans | FmNoInfs;
3232

3333
public:
3434
GenericMachineInstr() = delete;

llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,8 +1266,7 @@ class MachineIRBuilder {
12661266
///
12671267
/// \return a MachineInstrBuilder for the newly created instruction.
12681268
MachineInstrBuilder buildICmp(CmpInst::Predicate Pred, const DstOp &Res,
1269-
const SrcOp &Op0, const SrcOp &Op1,
1270-
std::optional<unsigned> Flags = std::nullopt);
1269+
const SrcOp &Op0, const SrcOp &Op1);
12711270

12721271
/// Build and insert a \p Res = G_FCMP \p Pred\p Op0, \p Op1
12731272
///

llvm/include/llvm/CodeGen/MachineInstr.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ class MachineInstr
119119
Disjoint = 1 << 19, // Each bit is zero in at least one of the inputs.
120120
NoUSWrap = 1 << 20, // Instruction supports geps
121121
// no unsigned signed wrap.
122-
SameSign = 1 << 21 // Both operands have the same sign.
123122
};
124123

125124
private:

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,17 +340,20 @@ bool IRTranslator::translateCompare(const User &U,
340340
Register Op1 = getOrCreateVReg(*U.getOperand(1));
341341
Register Res = getOrCreateVReg(U);
342342
CmpInst::Predicate Pred = CI->getPredicate();
343-
uint32_t Flags = MachineInstr::copyFlagsFromInstruction(*CI);
344343
if (CmpInst::isIntPredicate(Pred))
345-
MIRBuilder.buildICmp(Pred, Res, Op0, Op1, Flags);
344+
MIRBuilder.buildICmp(Pred, Res, Op0, Op1);
346345
else if (Pred == CmpInst::FCMP_FALSE)
347346
MIRBuilder.buildCopy(
348347
Res, getOrCreateVReg(*Constant::getNullValue(U.getType())));
349348
else if (Pred == CmpInst::FCMP_TRUE)
350349
MIRBuilder.buildCopy(
351350
Res, getOrCreateVReg(*Constant::getAllOnesValue(U.getType())));
352-
else
351+
else {
352+
uint32_t Flags = 0;
353+
if (CI)
354+
Flags = MachineInstr::copyFlagsFromInstruction(*CI);
353355
MIRBuilder.buildFCmp(Pred, Res, Op0, Op1, Flags);
356+
}
354357

355358
return true;
356359
}

llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -898,9 +898,8 @@ MachineIRBuilder::buildFPTrunc(const DstOp &Res, const SrcOp &Op,
898898
MachineInstrBuilder MachineIRBuilder::buildICmp(CmpInst::Predicate Pred,
899899
const DstOp &Res,
900900
const SrcOp &Op0,
901-
const SrcOp &Op1,
902-
std::optional<unsigned> Flags) {
903-
return buildInstr(TargetOpcode::G_ICMP, Res, {Pred, Op0, Op1}, Flags);
901+
const SrcOp &Op1) {
902+
return buildInstr(TargetOpcode::G_ICMP, Res, {Pred, Op0, Op1});
904903
}
905904

906905
MachineInstrBuilder MachineIRBuilder::buildFCmp(CmpInst::Predicate Pred,

llvm/lib/CodeGen/MIRParser/MILexer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ static MIToken::TokenKind getIdentifierKind(StringRef Identifier) {
216216
.Case("exact", MIToken::kw_exact)
217217
.Case("nneg", MIToken::kw_nneg)
218218
.Case("disjoint", MIToken::kw_disjoint)
219-
.Case("samesign", MIToken::kw_samesign)
220219
.Case("nofpexcept", MIToken::kw_nofpexcept)
221220
.Case("unpredictable", MIToken::kw_unpredictable)
222221
.Case("debug-location", MIToken::kw_debug_location)

llvm/lib/CodeGen/MIRParser/MILexer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ struct MIToken {
7777
kw_unpredictable,
7878
kw_nneg,
7979
kw_disjoint,
80-
kw_samesign,
8180
kw_debug_location,
8281
kw_debug_instr_number,
8382
kw_dbg_instr_ref,

llvm/lib/CodeGen/MIRParser/MIParser.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,8 +1476,7 @@ bool MIParser::parseInstruction(unsigned &OpCode, unsigned &Flags) {
14761476
Token.is(MIToken::kw_noconvergent) ||
14771477
Token.is(MIToken::kw_unpredictable) ||
14781478
Token.is(MIToken::kw_nneg) ||
1479-
Token.is(MIToken::kw_disjoint) ||
1480-
Token.is(MIToken::kw_samesign)) {
1479+
Token.is(MIToken::kw_disjoint)) {
14811480
// clang-format on
14821481
// Mine frame and fast math flags
14831482
if (Token.is(MIToken::kw_frame_setup))
@@ -1514,8 +1513,6 @@ bool MIParser::parseInstruction(unsigned &OpCode, unsigned &Flags) {
15141513
Flags |= MachineInstr::NonNeg;
15151514
if (Token.is(MIToken::kw_disjoint))
15161515
Flags |= MachineInstr::Disjoint;
1517-
if (Token.is(MIToken::kw_samesign))
1518-
Flags |= MachineInstr::SameSign;
15191516

15201517
lex();
15211518
}

llvm/lib/CodeGen/MIRPrinter.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,8 +837,6 @@ void MIPrinter::print(const MachineInstr &MI) {
837837
OS << "disjoint ";
838838
if (MI.getFlag(MachineInstr::NoUSWrap))
839839
OS << "nusw ";
840-
if (MI.getFlag(MachineInstr::SameSign))
841-
OS << "samesign ";
842840

843841
OS << TII->getName(MI.getOpcode());
844842
if (I < E)

llvm/lib/CodeGen/MachineInstr.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,6 @@ uint32_t MachineInstr::copyFlagsFromInstruction(const Instruction &I) {
596596
MIFlags |= MachineInstr::MIFlag::Disjoint;
597597
}
598598

599-
// Copy the samesign flag.
600-
if (const ICmpInst *ICmp = dyn_cast<ICmpInst>(&I))
601-
if (ICmp->hasSameSign())
602-
MIFlags |= MachineInstr::MIFlag::SameSign;
603-
604599
// Copy the exact flag.
605600
if (const PossiblyExactOperator *PE = dyn_cast<PossiblyExactOperator>(&I))
606601
if (PE->isExact())
@@ -1775,8 +1770,6 @@ void MachineInstr::print(raw_ostream &OS, ModuleSlotTracker &MST,
17751770
OS << "nneg ";
17761771
if (getFlag(MachineInstr::Disjoint))
17771772
OS << "disjoint ";
1778-
if (getFlag(MachineInstr::SameSign))
1779-
OS << "samesign ";
17801773

17811774
// Print the opcode name.
17821775
if (TII)

llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-samesign.ll

Lines changed: 0 additions & 69 deletions
This file was deleted.

llvm/test/CodeGen/MIR/icmp-flags.mir

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)