The inline assembly z constraint modifier is handled by the following code in RISCVAsmPrinter.cpp:
case 'z': // Print zero register if zero, regular printing otherwise. if (MO.isImm() && MO.getImm() == 0) { OS << RISCVInstPrinter::getRegisterName(RISCV::X0); return false; } break;
Because the test was using an r operand constraint, the condition MO.isImm() wouldn't trigger, so we didn't actually have a test for the z modifier. The zero we were seeing in the test CHECK line was unrelated to the modifier, and would even persist if the modifier wasn't used.
This patch changes the relevant tests to use an i constraint, which does trigger the z constraint modifier handling code.