Skip to content

Commit f724e88

Browse files
committed
[GlobalIsel] Import GEP flags
llvm#90824
1 parent 7f524f7 commit f724e88

File tree

3 files changed

+4269
-631
lines changed

3 files changed

+4269
-631
lines changed

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,10 +1583,8 @@ bool IRTranslator::translateGetElementPtr(const User &U,
15831583
LLT OffsetTy = getLLTForType(*OffsetIRTy, *DL);
15841584

15851585
uint32_t Flags = 0;
1586-
if (isa<Instruction>(U)) {
1587-
const Instruction &I = cast<Instruction>(U);
1588-
Flags = MachineInstr::copyFlagsFromInstruction(I);
1589-
}
1586+
if (const Instruction *I = dyn_cast<Instruction>(&U))
1587+
Flags = MachineInstr::copyFlagsFromInstruction(*I);
15901588

15911589
// Normalize Vector GEP - all scalar operands should be converted to the
15921590
// splat vector.

llvm/lib/CodeGen/MachineInstr.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,11 @@ uint32_t MachineInstr::copyFlagsFromInstruction(const Instruction &I) {
576576
MIFlags |= MachineInstr::MIFlag::NoSWrap;
577577
if (TI->hasNoUnsignedWrap())
578578
MIFlags |= MachineInstr::MIFlag::NoUWrap;
579+
} else if (const GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(&I)) {
580+
if (GEP->hasNoUnsignedSignedWrap())
581+
MIFlags |= MachineInstr::MIFlag::NoSWrap;
582+
if (GEP->hasNoUnsignedWrap())
583+
MIFlags |= MachineInstr::MIFlag::NoUWrap;
579584
}
580585

581586
// Copy the nonneg flag.

0 commit comments

Comments
 (0)