[Sparc] Remove cast that truncates immediate operands to 32 bits.
authorBrad Smith <brad@comstyle.com>
Sat, 3 Oct 2020 00:05:09 +0000 (20:05 -0400)
committerBrad Smith <brad@comstyle.com>
Sat, 3 Oct 2020 00:14:55 +0000 (20:14 -0400)
Patch by: Mark Kettenis

Test provided by Jessica Clarke.

Differential Revision: https://reviews.llvm.org/D87210

llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
llvm/test/CodeGen/SPARC/inlineasm-v9.ll

index 069e43c..7845a18 100644 (file)
@@ -351,7 +351,7 @@ void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
     break;
 
   case MachineOperand::MO_Immediate:
-    O << (int)MO.getImm();
+    O << MO.getImm();
     break;
   case MachineOperand::MO_MachineBasicBlock:
     MO.getMBB()->getSymbol()->print(O, MAI);
index 53ab114..1388c86 100644 (file)
@@ -39,3 +39,12 @@ entry:
   tail call void asm sideeffect "faddq $0,$1,$2", "{f40},{f40},{f40}"(fp128 0xL0, fp128 0xL0, fp128 0xL0)
   ret void
 }
+
+;; Ensure that 64-bit immediates aren't truncated
+; CHECK-LABEL: test_large_immediate
+; CHECK: or %o0, %lo(4294967296), %o0
+define i64 @test_large_immediate(i64) {
+entry:
+  %1 = tail call i64 asm "or $0, %lo($1), $0", "=r,i,r"(i64 4294967296, i64 %0)
+  ret i64 %1
+}