[llvm] 9ae95a0 - [Sparc] Remove cast that truncates immediate operands to 32 bits.

Brad Smith via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 17:15:33 PDT 2020


Author: Brad Smith
Date: 2020-10-02T20:14:55-04:00
New Revision: 9ae95a0f8f1bc9bd9e8eb30a5a9444fbdca5cc29

URL: https://github.com/llvm/llvm-project/commit/9ae95a0f8f1bc9bd9e8eb30a5a9444fbdca5cc29
DIFF: https://github.com/llvm/llvm-project/commit/9ae95a0f8f1bc9bd9e8eb30a5a9444fbdca5cc29.diff

LOG: [Sparc] Remove cast that truncates immediate operands to 32 bits.

Patch by: Mark Kettenis

Test provided by Jessica Clarke.

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp b/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
index 069e43c6f544..7845a18b14c1 100644
--- a/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
+++ b/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
@@ -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);

diff  --git a/llvm/test/CodeGen/SPARC/inlineasm-v9.ll b/llvm/test/CodeGen/SPARC/inlineasm-v9.ll
index 53ab114dd8d5..1388c8655ace 100644
--- a/llvm/test/CodeGen/SPARC/inlineasm-v9.ll
+++ b/llvm/test/CodeGen/SPARC/inlineasm-v9.ll
@@ -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
+}


        


More information about the llvm-commits mailing list