Index: lib/Target/PowerPC/PPCISelLowering.cpp =================================================================== --- lib/Target/PowerPC/PPCISelLowering.cpp +++ lib/Target/PowerPC/PPCISelLowering.cpp @@ -14309,6 +14309,17 @@ return std::make_pair(0U, &PPC::VSFRCRegClass); } + // If we name a VSX register, we can't defer to the base class because it + // will not recognize the correct register (their names will be VSL{0-31} + // and V{0-31} so they won't match). So we match them here. + if (Constraint.size() > 3 && Constraint[1] == 'v' && Constraint[2] == 's') { + int VSNum = atoi(Constraint.data() + 3); + assert(VSNum >= 0 && VSNum <= 63 && + "Attempted to access a vsr out of range"); + if (VSNum < 32) + return std::make_pair(PPC::VSL0 + VSNum, &PPC::VSRCRegClass); + return std::make_pair(PPC::V0 + VSNum - 32, &PPC::VSRCRegClass); + } std::pair R = TargetLowering::getRegForInlineAsmConstraint(TRI, Constraint, VT); Index: test/CodeGen/PowerPC/inline-asm-vsx-clobbers.ll =================================================================== --- test/CodeGen/PowerPC/inline-asm-vsx-clobbers.ll +++ test/CodeGen/PowerPC/inline-asm-vsx-clobbers.ll @@ -0,0 +1,32 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mcpu=pwr9 -mtriple=powerpc64le-unknown-unknown \ +; RUN: -enable-ppc-quad-precision -ppc-vsr-nums-as-vr \ +; RUN: -ppc-asm-full-reg-names < %s | FileCheck %s + +define dso_local void @clobberVR(<4 x i32> %a, <4 x i32> %b) local_unnamed_addr { +; CHECK-LABEL: clobberVR: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: stxv v22, -160(r1) # 16-byte Folded Spill +; CHECK-NEXT: #APP +; CHECK-NEXT: nop +; CHECK-NEXT: #NO_APP +; CHECK-NEXT: lxv v22, -160(r1) # 16-byte Folded Reload +; CHECK-NEXT: blr +entry: + tail call void asm sideeffect "nop", "~{vs54}"() + ret void +} + +define dso_local void @clobberFPR(<4 x i32> %a, <4 x i32> %b) local_unnamed_addr { +; CHECK-LABEL: clobberFPR: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: stfd f14, -144(r1) # 8-byte Folded Spill +; CHECK-NEXT: #APP +; CHECK-NEXT: nop +; CHECK-NEXT: #NO_APP +; CHECK-NEXT: lfd f14, -144(r1) # 8-byte Folded Reload +; CHECK-NEXT: blr +entry: + tail call void asm sideeffect "nop", "~{vs14}"() + ret void +}