[clang] [llvm] [AMDGPU] Fix monitor-sleep duration validation on GFX12.5 (PR #241042)
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 11 05:03:40 PST 2026
================
@@ -5554,16 +5554,25 @@ bool AMDGPUAsmParser::validateWMMA(const MCInst &Inst,
bool AMDGPUAsmParser::validateMonitorSleep(const MCInst &Inst,
const OperandVector &Operands) {
unsigned Opc = Inst.getOpcode();
- if (Opc != AMDGPU::S_MONITOR_SLEEP_gfx12 ||
- !getSTI().hasFeature(AMDGPU::FeatureNoSleepForever))
+ if (Opc != AMDGPU::S_MONITOR_SLEEP_gfx12)
return true;
int ImmIdx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::simm16);
- if (Inst.getOperand(ImmIdx).getImm() & 0x8000) {
+ int64_t Sleep = Inst.getOperand(ImmIdx).getImm();
+ // Accept the sign-extended spelling emitted for negative i16 operands.
+ if (isUInt<32>(Sleep) && isInt<16>(SignExtend64<32>(Sleep)))
+ Sleep = SignExtend64<32>(Sleep);
+ if (getSTI().hasFeature(AMDGPU::FeatureNoSleepForever) && (Sleep & 0x8000)) {
Error(getOperandLoc(Operands, ImmIdx),
"sleep forever is unsuported on the target");
return false;
}
+ if (getSTI().hasFeature(AMDGPU::FeatureMonitorSleep7BitDuration) &&
+ (Sleep < INT16_MIN || Sleep > UINT16_MAX || (Sleep & 0x7f80))) {
----------------
yxsamliu wrote:
The check now compares the duration with 127. The sleep-forever bit is checked separately.
https://github.com/llvm/llvm-project/pull/241042
More information about the cfe-commits
mailing list