[llvm-commits] [llvm] r54418 - in /llvm/trunk: lib/Target/X86/X86Instr64bit.td lib/Target/X86/X86InstrInfo.td test/CodeGen/X86/zext-inreg-0.ll test/CodeGen/X86/zext-inreg-2.ll

Dan Gohman gohman at apple.com
Wed Aug 6 11:27:22 PDT 2008


Author: djg
Date: Wed Aug  6 13:27:21 2008
New Revision: 54418

URL: http://llvm.org/viewvc/llvm-project?rev=54418&view=rev
Log:
Re-introduce the 8-bit subreg zext-inreg patterns for x86-32,
this time using MOV32to32_ and MOV16to16_. Thanks to Evan for
suggesting this.

Removed:
    llvm/trunk/test/CodeGen/X86/zext-inreg-2.ll
Modified:
    llvm/trunk/lib/Target/X86/X86Instr64bit.td
    llvm/trunk/lib/Target/X86/X86InstrInfo.td
    llvm/trunk/test/CodeGen/X86/zext-inreg-0.ll

Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=54418&r1=54417&r2=54418&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original)
+++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Wed Aug  6 13:27:21 2008
@@ -1251,12 +1251,6 @@
 // r & (2^8-1) ==> movz
 def : Pat<(and GR64:$src, 0xff),
           (MOVZX64rr8 (i8 (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit)))>;
-
-// TODO: The following two patterns could be adapted to apply to x86-32, except
-// that they'll need some way to deal with the fact that in x86-32 not all GPRs
-// have 8-bit subregs. The GR32_ and GR16_ classes are a step in this direction,
-// but they aren't ready for this purpose yet.
-
 // r & (2^8-1) ==> movz
 def : Pat<(and GR32:$src1, 0xff),
            (MOVZX32rr8 (i8 (EXTRACT_SUBREG GR32:$src1, x86_subreg_8bit)))>,

Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=54418&r1=54417&r2=54418&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Wed Aug  6 13:27:21 2008
@@ -2774,6 +2774,16 @@
 // r & (2^16-1) ==> movz
 def : Pat<(and GR32:$src1, 0xffff),
            (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
+// r & (2^8-1) ==> movz
+def : Pat<(and GR32:$src1, 0xff),
+           (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
+                                           x86_subreg_8bit)))>,
+      Requires<[In32BitMode]>;
+// r & (2^8-1) ==> movz
+def : Pat<(and GR16:$src1, 0xff),
+           (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
+                                           x86_subreg_8bit)))>,
+      Requires<[In32BitMode]>;
 
 // (shl x, 1) ==> (add x, x)
 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr  GR8 :$src1, GR8 :$src1)>;

Modified: llvm/trunk/test/CodeGen/X86/zext-inreg-0.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/zext-inreg-0.ll?rev=54418&r1=54417&r2=54418&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/zext-inreg-0.ll (original)
+++ llvm/trunk/test/CodeGen/X86/zext-inreg-0.ll Wed Aug  6 13:27:21 2008
@@ -8,11 +8,26 @@
 ; These should use movzbl instead of 'and 255'.
 ; This related to not having a ZERO_EXTEND_REG opcode.
 
+define i32 @a(i32 %d) nounwind  {
+        %e = add i32 %d, 1
+        %retval = and i32 %e, 255
+        ret i32 %retval
+}
+define i32 @b(float %d) nounwind  {
+        %tmp12 = fptoui float %d to i8
+        %retval = zext i8 %tmp12 to i32
+        ret i32 %retval
+}
 define i32 @c(i32 %d) nounwind  {
         %e = add i32 %d, 1
         %retval = and i32 %e, 65535
         ret i32 %retval
 }
+define i64 @d(i64 %d) nounwind  {
+        %e = add i64 %d, 1
+        %retval = and i64 %e, 255
+        ret i64 %retval
+}
 define i64 @e(i64 %d) nounwind  {
         %e = add i64 %d, 1
         %retval = and i64 %e, 65535

Removed: llvm/trunk/test/CodeGen/X86/zext-inreg-2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/zext-inreg-2.ll?rev=54417&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/X86/zext-inreg-2.ll (original)
+++ llvm/trunk/test/CodeGen/X86/zext-inreg-2.ll (removed)
@@ -1,28 +0,0 @@
-; RUN: llvm-as < %s | llc -march=x86-64 > %t
-; RUN: not grep and %t
-; RUN: not grep movzbq %t
-; RUN: not grep movzwq %t
-; RUN: not grep movzlq %t
-
-; These should use movzbl instead of 'and 255'.
-; This related to not having a ZERO_EXTEND_REG opcode.
-
-; This test was split out of zext-inreg-0.ll because these
-; cases don't yet work on x86-32 due to the 8-bit subreg
-; issue.
-
-define i32 @a(i32 %d) nounwind  {
-        %e = add i32 %d, 1
-        %retval = and i32 %e, 255
-        ret i32 %retval
-}
-define i32 @b(float %d) nounwind  {
-        %tmp12 = fptoui float %d to i8
-        %retval = zext i8 %tmp12 to i32
-        ret i32 %retval
-}
-define i64 @d(i64 %d) nounwind  {
-        %e = add i64 %d, 1
-        %retval = and i64 %e, 255
-        ret i64 %retval
-}





More information about the llvm-commits mailing list