[PowerPC] Replace cntlz[.] with cntlzw[.]
authorHal Finkel <hfinkel@anl.gov>
Wed, 28 Oct 2015 03:26:45 +0000 (03:26 +0000)
committerHal Finkel <hfinkel@anl.gov>
Wed, 28 Oct 2015 03:26:45 +0000 (03:26 +0000)
cntlz is the old POWER mnemonic. cntlzw is the PowerPC mnemonic.

This change fixes an issue when -no-integrated-as: The opcode cntlz is
unrecognized by gas

Alias the POWER mnemonic cntlz[.] to the PowerPC mnemonic cntlzw[.]
This is done for because the POWER cntlz mnemonic has be used by LLVM for
a very long time. We need to make sure that assembly programs
that are using the cntlz[.] do not break with this change.

Change PowerPC tests to reflect the insn change from cntlz to cntlzw.
Add assembly test to verify cntlz[.] is encoded correctly.

Patch by Tom Rix!

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

lib/Target/PowerPC/PPCInstrInfo.td
test/CodeGen/PowerPC/cttz.ll
test/CodeGen/PowerPC/long-compare.ll
test/CodeGen/PowerPC/seteq-0.ll
test/MC/Disassembler/PowerPC/ppc64-encoding.txt
test/MC/Disassembler/PowerPC/ppc64le-encoding.txt
test/MC/PowerPC/ppc64-encoding.s

index 24fd9bd5c1f723c6043d09bec503c45f5dde42c0..cc1af1a7132ffe66552ccc2dfc44894e57a2035d 100644 (file)
@@ -3883,8 +3883,11 @@ def : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNMo gprc:$rA, gprc:$rS, gprc:$rB, 0,
 def : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
 def : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
 
-def : InstAlias<"cntlz $rA, $rS", (CNTLZW gprc:$rA, gprc:$rS)>;
-def : InstAlias<"cntlz. $rA, $rS", (CNTLZWo gprc:$rA, gprc:$rS)>;
+def : InstAlias<"cntlzw $rA, $rS", (CNTLZW gprc:$rA, gprc:$rS)>;
+def : InstAlias<"cntlzw. $rA, $rS", (CNTLZWo gprc:$rA, gprc:$rS)>;
+// The POWER variant
+def : MnemonicAlias<"cntlz",  "cntlzw">;
+def : MnemonicAlias<"cntlz.", "cntlzw.">;
 
 def EXTLDI : PPCAsmPseudo<"extldi $rA, $rS, $n, $b",
                           (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
index 60de982d91a1311401ce6d9490338dd87f2f7e35..3757fa3e2f2970b6901bace30514056aa193b35b 100644 (file)
@@ -6,7 +6,7 @@ declare i32 @llvm.cttz.i32(i32, i1)
 define i32 @bar(i32 %x) {
 entry:
 ; CHECK: @bar
-; CHECK: cntlz
+; CHECK: cntlzw
         %tmp.1 = call i32 @llvm.cttz.i32( i32 %x, i1 true )              ; <i32> [#uses=1]
         ret i32 %tmp.1
 }
index e53356a5ddf23f3d18e5cd94c1c2b35864d42b28..d596068cbb715edb6862afdc403baa644e3116dd 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc < %s -march=ppc32 | grep cntlz
+; RUN: llc < %s -march=ppc32 | grep cntlzw
 ; RUN: llc < %s -march=ppc32 | not grep xori 
 ; RUN: llc < %s -march=ppc32 | not grep "li "
 ; RUN: llc < %s -march=ppc32 | not grep "mr "
index 4afb8fee1776e6c2ae629fff4884b8cdb12d1d6d..b7dd78085eb12230b151e45f9ace7eeb7ae68927 100644 (file)
@@ -5,7 +5,7 @@ define i32 @eq0(i32 %a) {
         %tmp.2 = zext i1 %tmp.1 to i32          ; <i32> [#uses=1]
         ret i32 %tmp.2
 
-; CHECK: cntlz [[REG:r[0-9]+]], r3
+; CHECK: cntlzw [[REG:r[0-9]+]], r3
 ; CHECK: rlwinm r3, [[REG]], 27, 31, 31
 ; CHECK: blr
 }
index f235c242fbce5a5b3ff057c43ba3ab96f16d27e1..74023340d500bb46958cc149e7e6ee6e4b036de2 100644 (file)
 # CHECK: extsh. 2, 3                     
 0x7c 0x62 0x07 0x35
 
-# CHECK: cntlz 2, 3
+# CHECK: cntlzw 2, 3
 0x7c 0x62 0x00 0x34
 
-# CHECK: cntlz. 2, 3
+# CHECK: cntlzw. 2, 3
 0x7c 0x62 0x00 0x35
 
 # CHECK: popcntw 2, 3                    
index f154e00ff51c43870f1a9764976784ea754bb53a..9ddc286d8aaa155be2c57a1c2dd76bfb7c1639a9 100644 (file)
 # CHECK: extsh. 2, 3
 0x35 0x07 0x62 0x7c
 
-# CHECK: cntlz 2, 3
+# CHECK: cntlzw 2, 3
 0x34 0x00 0x62 0x7c
 
-# CHECK: cntlz. 2, 3
+# CHECK: cntlzw. 2, 3
 0x35 0x00 0x62 0x7c
 
 # CHECK: popcntw 2, 3
index 4a698adadda38f582061164d1688c074e023c4a6..b2aac8874ffe6eba6b3bb682e66f4f6c4c0e3b32 100644 (file)
 # CHECK-LE: extsh. 2, 3                     # encoding: [0x35,0x07,0x62,0x7c]
             extsh. 2, 3
 
-# CHECK-BE: cntlz 2, 3                     # encoding: [0x7c,0x62,0x00,0x34]
-# CHECK-LE: cntlz 2, 3                     # encoding: [0x34,0x00,0x62,0x7c]
+# CHECK-BE: cntlzw 2, 3                     # encoding: [0x7c,0x62,0x00,0x34]
+# CHECK-LE: cntlzw 2, 3                     # encoding: [0x34,0x00,0x62,0x7c]
             cntlzw 2, 3
-# CHECK-BE: cntlz. 2, 3                    # encoding: [0x7c,0x62,0x00,0x35]
-# CHECK-LE: cntlz. 2, 3                    # encoding: [0x35,0x00,0x62,0x7c]
+# CHECK-BE: cntlzw. 2, 3                    # encoding: [0x7c,0x62,0x00,0x35]
+# CHECK-LE: cntlzw. 2, 3                    # encoding: [0x35,0x00,0x62,0x7c]
             cntlzw. 2, 3
-# CHECK-BE: cntlz 2, 3                     # encoding: [0x7c,0x62,0x00,0x34]
-# CHECK-LE: cntlz 2, 3                     # encoding: [0x34,0x00,0x62,0x7c]
-            cntlz  2, 3
-# CHECK-BE: cntlz. 2, 3                    # encoding: [0x7c,0x62,0x00,0x35]
-# CHECK-LE: cntlz. 2, 3                    # encoding: [0x35,0x00,0x62,0x7c]
-            cntlz.  2, 3
+#
+# The POWER variant of cntlzw
+# CHECK-BE: cntlzw 2, 3                     # encoding: [0x7c,0x62,0x00,0x34]
+# CHECK-LE: cntlzw 2, 3                     # encoding: [0x34,0x00,0x62,0x7c]
+            cntlz 2, 3
+# CHECK-BE: cntlzw. 2, 3                    # encoding: [0x7c,0x62,0x00,0x35]
+# CHECK-LE: cntlzw. 2, 3                    # encoding: [0x35,0x00,0x62,0x7c]
+            cntlz. 2, 3
             cmpb 7, 21, 4
 # CHECK-BE: cmpb 7, 21, 4                   # encoding: [0x7e,0xa7,0x23,0xf8]
 # CHECK-LE: cmpb 7, 21, 4                   # encoding: [0xf8,0x23,0xa7,0x7e]