Skip to content

Commit

Permalink
Merge pull request mono/mono#17279 from imhameed/bug-gh-16935-netcore…
Browse files Browse the repository at this point in the history
…-equalsall-codegen

Generate LLVM IR for OP_XEQUAL that is recognized by LLVM's vector pattern recognizers.

Commit migrated from mono/mono@8836231
  • Loading branch information
imhameed authored Oct 18, 2019
2 parents e31a5f8 + 2cf956e commit f2e4a2f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/mono/mono/mini/mini-llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -7371,15 +7371,26 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
LLVMValueRef cmp, mask [32], shuffle;
int nelems;

LLVMTypeRef srcelemt = LLVMGetElementType (LLVMTypeOf (lhs));

//%c = icmp sgt <16 x i8> %a0, %a1
if (LLVMGetElementType (LLVMTypeOf (lhs)) == LLVMDoubleType () || LLVMGetElementType (LLVMTypeOf (lhs)) == LLVMFloatType ())
if (srcelemt == LLVMDoubleType () || srcelemt == LLVMFloatType ())
cmp = LLVMBuildFCmp (builder, LLVMRealOEQ, lhs, rhs, "");
else
cmp = LLVMBuildICmp (builder, LLVMIntEQ, lhs, rhs, "");
nelems = LLVMGetVectorSize (LLVMTypeOf (cmp));
t = LLVMVectorType (LLVMInt8Type (), nelems);

LLVMTypeRef elemt;
if (srcelemt == LLVMDoubleType ())
elemt = LLVMInt64Type ();
else if (srcelemt == LLVMFloatType ())
elemt = LLVMInt32Type ();
else
elemt = srcelemt;

t = LLVMVectorType (elemt, nelems);
cmp = LLVMBuildSExt (builder, cmp, t, "");
// cmp is a <16 x i8> vector, each element is either 0xff or 0
// cmp is a <nelems x elemt> vector, each element is either 0xff... or 0
int half = nelems / 2;
while (half >= 1) {
// AND the top and bottom halfes into the bottom half
Expand Down

0 comments on commit f2e4a2f

Please sign in to comment.