[PATCH] D53460: [X86] When checking the bits in cpu_features for function multiversioning dispatcher in the resolver, make sure all the required bits are set. Not just one of them
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 19 18:32:07 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344824: [X86] When checking the bits in cpu_features for function multiversioning… (authored by ctopper, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D53460?vs=170276&id=170290#toc
Repository:
rL LLVM
https://reviews.llvm.org/D53460
Files:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/attr-target-mv.c
cfe/trunk/test/CodeGen/builtin-cpu-supports.c
Index: cfe/trunk/test/CodeGen/builtin-cpu-supports.c
===================================================================
--- cfe/trunk/test/CodeGen/builtin-cpu-supports.c
+++ cfe/trunk/test/CodeGen/builtin-cpu-supports.c
@@ -14,7 +14,7 @@
// CHECK: [[LOAD:%[^ ]+]] = load i32, i32* getelementptr inbounds ({ i32, i32, i32, [1 x i32] }, { i32, i32, i32, [1 x i32] }* @__cpu_model, i32 0, i32 3, i32 0)
// CHECK: [[AND:%[^ ]+]] = and i32 [[LOAD]], 256
- // CHECK: = icmp ne i32 [[AND]], 0
+ // CHECK: = icmp eq i32 [[AND]], 256
return 0;
}
Index: cfe/trunk/test/CodeGen/attr-target-mv.c
===================================================================
--- cfe/trunk/test/CodeGen/attr-target-mv.c
+++ cfe/trunk/test/CodeGen/attr-target-mv.c
@@ -70,6 +70,22 @@
// CHECK: ret void ()* @foo_decls.sse4.2
// CHECK: ret void ()* @foo_decls
+// CHECK: define void @bar4()
+// CHECK: call void @foo_multi.ifunc()
+
+// CHECK: define void ()* @foo_multi.resolver() comdat
+// CHECK: and i32 %{{.*}}, 4352
+// CHECK: icmp eq i32 %{{.*}}, 4352
+// CHECK: ret void ()* @foo_multi.fma4_sse4.2
+// CHECK: icmp eq i32 %{{.*}}, 12
+// CHECK: and i32 %{{.*}}, 4352
+// CHECK: icmp eq i32 %{{.*}}, 4352
+// CHECK: ret void ()* @foo_multi.arch_ivybridge_fma4_sse4.2
+// CHECK: and i32 %{{.*}}, 768
+// CHECK: icmp eq i32 %{{.*}}, 768
+// CHECK: ret void ()* @foo_multi.avx_sse4.2
+// CHECK: ret void ()* @foo_multi
+
// CHECK: declare i32 @foo.arch_sandybridge()
// CHECK: define available_externally i32 @foo_inline.sse4.2()
@@ -88,4 +104,3 @@
// CHECK: define available_externally void @foo_multi.avx_sse4.2()
// CHECK: define available_externally void @foo_multi.fma4_sse4.2()
// CHECK: define available_externally void @foo_multi.arch_ivybridge_fma4_sse4.2()
-
Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -9129,9 +9129,9 @@
Builder.CreateAlignedLoad(CpuFeatures, CharUnits::fromQuantity(4));
// Check the value of the bit corresponding to the feature requested.
- Value *Bitset = Builder.CreateAnd(
- Features, llvm::ConstantInt::get(Int32Ty, FeaturesMask));
- return Builder.CreateICmpNE(Bitset, llvm::ConstantInt::get(Int32Ty, 0));
+ Value *Mask = Builder.getInt32(FeaturesMask);
+ Value *Bitset = Builder.CreateAnd(Features, Mask);
+ return Builder.CreateICmpEQ(Bitset, Mask);
}
Value *CodeGenFunction::EmitX86CpuInit() {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53460.170290.patch
Type: text/x-patch
Size: 2514 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181020/59d19a83/attachment.bin>
More information about the cfe-commits
mailing list