Don't use %g0 to materialize 0 directly.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Sun, 19 May 2013 21:47:13 +0000 (21:47 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Sun, 19 May 2013 21:47:13 +0000 (21:47 +0000)
The wired physreg doesn't work on tied operands like on MOVXCC.

Add a README note to fix this later.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182225 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Sparc/README.txt
lib/Target/Sparc/SparcInstr64Bit.td
test/CodeGen/SPARC/64bit.ll
test/CodeGen/SPARC/64cond.ll

index b4991fe5790b705e6dfa5a8e4bfc5aa351ded1ea..c831367e436cf0fbddfd84e6a5827557e39645fe 100644 (file)
@@ -57,3 +57,5 @@ int %t1(int %a, int %b) {
 * Fill delay slots
 
 * Implement JIT support
+
+* Use %g0 directly to materialize 0. No instruction is required.
index 3af494ee0c74b3cc89ca5cdfc36162d749e8b5f3..daafb432372420d015df0b4c8aaaa5b6a8060a48 100644 (file)
@@ -59,10 +59,6 @@ defm SRAX : F3_S<"srax", 0b100111, 1, sra, i64, I64Regs>;
 // preferable to use a constant pool load instead, depending on the
 // microarchitecture.
 
-// The %g0 register is constant 0.
-// This is useful for stx %g0, [...], for example.
-def : Pat<(i64 0), (i64 G0)>, Requires<[Is64Bit]>;
-
 // Single-instruction patterns.
 
 // The ALU instructions want their simm13 operands as i32 immediates.
index 37dcea9891d29a1de6f9be81fc04236bfecf7a97..dd6cee30b15803f0cc3b80b2cc22dc9faa70d172 100644 (file)
@@ -26,7 +26,7 @@ define i64 @sra_reg(i64 %a, i64 %b) {
 ;     restore %g0, %g0, %o0
 ;
 ; CHECK: ret_imm0
-; CHECK: or %g0, %g0, %i0
+; CHECK: or %g0, 0, %i0
 define i64 @ret_imm0() {
   ret i64 0
 }
index 0c025b36e3b3b5bb09e1c03279434bd1d3d96753..594eff6f5545333fe481e5fbe4620b0d604ce234 100644 (file)
@@ -98,3 +98,14 @@ entry:
   %rv = select i1 %tobool, double %a, double %b
   ret double %rv
 }
+
+; The MOVXCC instruction can't use %g0 for its tied operand.
+; CHECK: select_consti64_xcc
+; CHECK: subcc
+; CHECK: movg %xcc, 123, %i0
+define i64 @select_consti64_xcc(i64 %x, i64 %y) {
+entry:
+  %tobool = icmp sgt i64 %x, %y
+  %rv = select i1 %tobool, i64 123, i64 0
+  ret i64 %rv
+}