Skip to content

Commit c3a638c

Browse files
authored
[GlobalISel] Fix silently dropped MIFlags on selected instructions (#138851)
We used uint16 for flags but flags now go up to 24 bits, so all flags in bits 16-24 were lost. Fixes #110801
1 parent a83bb35 commit c3a638c

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutorImpl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ bool GIMatchTableExecutor::executeMatchTable(
6161
// Bypass the flag check on the instruction, and only look at the MCInstrDesc.
6262
bool NoFPException = !State.MIs[0]->getDesc().mayRaiseFPException();
6363

64-
const uint16_t Flags = State.MIs[0]->getFlags();
64+
const uint32_t Flags = State.MIs[0]->getFlags();
6565

6666
enum RejectAction { RejectAndGiveUp, RejectAndResume };
6767
auto handleReject = [&]() -> RejectAction {
@@ -80,7 +80,7 @@ bool GIMatchTableExecutor::executeMatchTable(
8080
for (auto MIB : OutMIs) {
8181
// Set the NoFPExcept flag when no original matched instruction could
8282
// raise an FP exception, but the new instruction potentially might.
83-
uint16_t MIBFlags = Flags | MIB.getInstr()->getFlags();
83+
uint32_t MIBFlags = Flags | MIB.getInstr()->getFlags();
8484
if (NoFPException && MIB->mayRaiseFPException())
8585
MIBFlags |= MachineInstr::NoFPExcept;
8686
if (Observer)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
2+
# RUN: llc -mtriple=amdgcn-- -run-pass=instruction-select -o - %s | FileCheck %s
3+
4+
# Checks MI Flags are preserved on selected instructions.
5+
6+
---
7+
name: s_or_i32_disjoint
8+
tracksRegLiveness: true
9+
regBankSelected: true
10+
legalized: true
11+
body: |
12+
bb.0:
13+
liveins: $sgpr0, $sgpr1
14+
15+
; CHECK-LABEL: name: s_or_i32_disjoint
16+
; CHECK: liveins: $sgpr0, $sgpr1
17+
; CHECK-NEXT: {{ $}}
18+
; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
19+
; CHECK-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
20+
; CHECK-NEXT: [[S_OR_B32_:%[0-9]+]]:sreg_32 = disjoint S_OR_B32 [[COPY]], [[COPY1]], implicit-def dead $scc
21+
; CHECK-NEXT: $sgpr0 = COPY [[S_OR_B32_]]
22+
; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $sgpr0
23+
%0:sgpr(s32) = COPY $sgpr0
24+
%1:sgpr(s32) = COPY $sgpr1
25+
%2:sgpr(s32) = disjoint G_OR %0, %1
26+
$sgpr0 = COPY %2
27+
SI_RETURN_TO_EPILOG implicit $sgpr0
28+
...

0 commit comments

Comments
 (0)