Skip to content

[CIR][CIRGen][Builtin][X86] Lower insert* intrinsics #1829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RiverDave
Copy link
Collaborator

Only one thing to note related to the shuffles performed for these intrinsics. We could tackle this in a different PR tho.

OG's builder creates unary shuffles by passing a poison value for the second vector operand.

/// Create a unary shuffle. The second vector operand of the IR instruction
/// is poison.
Value *CreateShuffleVector(Value *V, ArrayRef<int> Mask,
                             const Twine &Name = “”) {
    return CreateShuffleVector(V, PoisonValue::get(V->getType()), Mask, Name);
}

In CIR, we currently work around this by duplicating the single vector argument as both operands:

    cir::VecShuffleOp createVecShuffle(mlir::Location loc, mlir::Value vec1,
                                     llvm::ArrayRef<int64_t> mask) {
    // FIXME(cir): Support use cir.vec.shuffle with single vec
    // Workaround: pass Vec as both vec1 and vec2
    return createVecShuffle(loc, vec1, vec1, mask);
}

While this is just a minor nit and I don’t believe we provoke a semantic difference, should we revisit the workaround stated in the comment for parity with OG?

@bcardosolopes
Copy link
Member

While this is just a minor nit and I don’t believe we provoke a semantic difference, should we revisit the workaround stated in the comment for parity with OG?

That'd be great for a new PR!

@bcardosolopes
Copy link
Member

Good after macOS-13 tests pass (also conflict resolution needed)

@bcardosolopes
Copy link
Member

tests still failing (only the windows one is ignorable at this point)

@RiverDave
Copy link
Collaborator Author

RiverDave commented Aug 21, 2025

tests still failing (only the windows one is ignorable at this point)

Yeah, I'm still trying to figure this out. For some reason I cannot reproduce this failure locally. Will investigate this further

return _mm256_insertf128_pd(a, b, 0);
}

// CIR-LABEL: @test_mm256_insertf128_pd_1(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes LABEL is tricky to use, you can try a match with just CIR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants