OSDN Git Service

[X86] Fix pattern match for 32-to-64-bit zext in the presence of AssertSext
authorMichael Kuperstein <michael.m.kuperstein@intel.com>
Mon, 10 Nov 2014 20:40:21 +0000 (20:40 +0000)
committerMichael Kuperstein <michael.m.kuperstein@intel.com>
Mon, 10 Nov 2014 20:40:21 +0000 (20:40 +0000)
This fixes an issue with matching trunc -> assertsext -> zext on x86-64, which would not zero the high 32-bits.
See PR20494 for details.

Differential Revision: http://reviews.llvm.org/D6128

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

lib/Target/X86/X86InstrCompiler.td
test/CodeGen/X86/TruncAssertZext.ll [new file with mode: 0644]

index bf25672..117b6ff 100644 (file)
@@ -1191,6 +1191,7 @@ def def32 : PatLeaf<(i32 GR32:$src), [{
   return N->getOpcode() != ISD::TRUNCATE &&
          N->getOpcode() != TargetOpcode::EXTRACT_SUBREG &&
          N->getOpcode() != ISD::CopyFromReg &&
+         N->getOpcode() != ISD::AssertSext &&
          N->getOpcode() != X86ISD::CMOV;
 }]>;
 
diff --git a/test/CodeGen/X86/TruncAssertZext.ll b/test/CodeGen/X86/TruncAssertZext.ll
new file mode 100644 (file)
index 0000000..08079e9
--- /dev/null
@@ -0,0 +1,16 @@
+; RUN: llc < %s -O2 -march=x86-64 | FileCheck %s\r
+; Checks that a zeroing mov is inserted for the trunc/zext pair even when\r
+; the source of the zext is an AssertSext node\r
+; PR20494\r
+\r
+define i64 @main(i64 %a) { \r
+; CHECK-LABEL: main\r
+; CHECK: movl %ecx, %eax\r
+; CHECK: ret\r
+  %or = or i64 %a, -2\r
+  %trunc = trunc i64 %or to i32\r
+  br label %l\r
+l:\r
+  %ext = zext i32 %trunc to i64\r
+  ret i64 %ext\r
+}\r