Fix a bug in the integer-promotion of bitcast operations on vector types.
authorNadav Rotem <nadav.rotem@intel.com>
Thu, 8 Dec 2011 13:10:01 +0000 (13:10 +0000)
committerNadav Rotem <nadav.rotem@intel.com>
Thu, 8 Dec 2011 13:10:01 +0000 (13:10 +0000)
We must not issue a bitcast operation for integer-promotion of vector types, because the
location of the values in the vector may be different.

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

lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
test/CodeGen/X86/2011-12-8-bitcastintprom.ll [new file with mode: 0644]
test/CodeGen/X86/vec_compare-2.ll
test/CodeGen/X86/widen_arith-3.ll

index fd24238a91659f85c95ae256b7a6647ad89857ee..a48ee7efdc8d06ff093b9441df9c0551d209f6e1 100644 (file)
@@ -216,7 +216,7 @@ SDValue DAGTypeLegalizer::PromoteIntRes_BITCAST(SDNode *N) {
   case TargetLowering::TypeLegal:
     break;
   case TargetLowering::TypePromoteInteger:
-    if (NOutVT.bitsEq(NInVT))
+    if (NOutVT.bitsEq(NInVT) && !NOutVT.isVector() && !NInVT.isVector())
       // The input promotes to the same size.  Convert the promoted value.
       return DAG.getNode(ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
     break;
diff --git a/test/CodeGen/X86/2011-12-8-bitcastintprom.ll b/test/CodeGen/X86/2011-12-8-bitcastintprom.ll
new file mode 100644 (file)
index 0000000..ceee8e6
--- /dev/null
@@ -0,0 +1,15 @@
+; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=corei7 | FileCheck %s
+
+; Make sure that the conversion between v4i8 to v2i16 is not a simple bitcast.
+; CHECK: prom_bug
+; CHECK: movd
+; CHECK: shufb
+; CHECK: movw
+; CHECK: ret
+define void @prom_bug(<4 x i8> %t, i16* %p) {
+  %r = bitcast <4 x i8> %t to <2 x i16>
+  %o = extractelement <2 x i16> %r, i32 0
+  store i16 %o, i16* %p
+  ret void
+}
+
index 04bb7254fb0823b07ebc0baf0dcea26c0a4fe769..aaa585b35f53759d6a5c9fc72f60df58a31b9ac9 100644 (file)
@@ -8,6 +8,7 @@ declare <4 x i32> @llvm.x86.sse41.pmaxsd(<4 x i32>, <4 x i32>) nounwind readnone
 
 define void @blackDespeckle_wrapper(i8** %args_list, i64* %gtid, i64 %xend) {
 entry:
+; CHECK: cfi_def_cfa_offset
 ; CHECK-NOT: set
 ; CHECK: pcmpgt
 ; CHECK: blendvps
index 11d56f57864480d62e0d33f154595fe57dea3955..b959ce82c9a81ab30c5795d0301a0e37016f31f7 100644 (file)
@@ -1,5 +1,5 @@
 ; RUN: llc < %s -march=x86 -mattr=+sse42 -post-RA-scheduler=true | FileCheck %s
-; CHECK: incw
+; CHECK: incl
 ; CHECK: incl
 ; CHECK: incl
 ; CHECK: addl