Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp =================================================================== --- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -363,6 +363,12 @@ O << "0, "; printOperand(MI, OpNo, O); return false; + case 'I': + // Write 'i' if an integer constant, otherwise nothing. Used to print + // addi vs add, etc. + if (MI->getOperand(OpNo).isImm()) + O << "i"; + return false; case 'U': // Print 'u' for update form. case 'X': // Print 'x' for indexed form. // FIXME: Currently for PowerPC memory operands are always loaded Index: llvm/test/CodeGen/PowerPC/asm-template-I.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/PowerPC/asm-template-I.ll @@ -0,0 +1,33 @@ +; https://bugs.llvm.org/show_bug.cgi?id=50608 +; RUN: llc -verify-machineinstrs < %s -mtriple=ppc64le-- + +; ModuleID = 'asm.c' +source_filename = "asm.c" +target datalayout = "e-m:e-i64:64-n32:64" +target triple = "ppc64le" + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local signext i32 @main(i32 signext %argc, i8** %argv) #0 { +entry: + %retval = alloca i32, align 4 + %argc.addr = alloca i32, align 4 + %argv.addr = alloca i8**, align 8 + store i32 0, i32* %retval, align 4 + store i32 %argc, i32* %argc.addr, align 4 + store i8** %argv, i8*** %argv.addr, align 8 + %0 = load i32, i32* %argc.addr, align 4 + call void asm sideeffect " .asciz \22${0:n}@${1:I}$1\22 ", "n,nZr"(i32 1, i32 %0) #1, !srcloc !4 + ret i32 0 +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="ppc64le" "target-features"="+altivec,+bpermd,+crypto,+direct-move,+extdiv,+htm,+power8-vector,+vsx,-power9-vector,-privileged,-rop-protect,-spe" } +attributes #1 = { nounwind } + +!llvm.module.flags = !{!0, !1, !2} +!llvm.ident = !{!3} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"uwtable", i32 1} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{!"clang version 13.0.0 (https://github.com/llvm/llvm-project.git bf65debed4ca53d646219182fff3655a857e3f2b)"} +!4 = !{i32 53}