[llvm] 9611958 - [InstCombine] Add test cases to show bad canonicalization of bitcasts between x86_mmx and <1 x i64>.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 7 12:42:17 PST 2019


Author: Craig Topper
Date: 2019-11-07T12:41:57-08:00
New Revision: 96119586c9968f3c1e56513d52956f5738cf4d26

URL: https://github.com/llvm/llvm-project/commit/96119586c9968f3c1e56513d52956f5738cf4d26
DIFF: https://github.com/llvm/llvm-project/commit/96119586c9968f3c1e56513d52956f5738cf4d26.diff

LOG: [InstCombine] Add test cases to show bad canonicalization of bitcasts between x86_mmx and <1 x i64>.

As the test cases show, we end up with an insert/extract and a
bitcast to/from i64. x86_mmx is for some purposes conceptually a
vector. We shouldn't be adding scalar conversions around it.

Since _m64 is defined as <1 x i64> and intrinsics use x86_mmx
as their input/output these extra scalar operations prevent
the X86 backend from generating good code especially on 32-bit
targets where i64 gets split.

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/bitcast-vec-canon.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/bitcast-vec-canon.ll b/llvm/test/Transforms/InstCombine/bitcast-vec-canon.ll
index a92a7b73fd7e..8b408e746b4a 100644
--- a/llvm/test/Transforms/InstCombine/bitcast-vec-canon.ll
+++ b/llvm/test/Transforms/InstCombine/bitcast-vec-canon.ll
@@ -38,3 +38,22 @@ define <1 x i64> @d(i64 %y) {
   ret <1 x i64> %c
 }
 
+define x86_mmx @e(<1 x i64> %y) {
+; CHECK-LABEL: @e(
+; CHECK-NEXT:    [[TMP1:%.*]] = extractelement <1 x i64> %y, i32 0
+; CHECK-NEXT:    [[C:%.*]] = bitcast i64 [[TMP1]] to x86_mmx
+; CHECK-NEXT:    ret x86_mmx [[C]]
+;
+  %c = bitcast <1 x i64> %y to x86_mmx
+  ret x86_mmx %c
+}
+
+define <1 x i64> @f(x86_mmx %y) {
+; CHECK-LABEL: @f(
+; CHECK-NEXT:    [[TMP1:%.*]] = bitcast x86_mmx %y to i64
+; CHECK-NEXT:    [[C:%.*]] = insertelement <1 x i64> undef, i64 [[TMP1]], i32 0
+; CHECK-NEXT:    ret <1 x i64> [[C]]
+;
+  %c = bitcast x86_mmx %y to <1 x i64>
+  ret <1 x i64> %c
+}


        


More information about the llvm-commits mailing list