Skip to content

[X86] EmitX86BuiltinExpr - attempt to convert SSE41/AVX1 roundps/d/ss/sd builtins to regular rounding modes #170273

@RKSimon

Description

@RKSimon

Certain rounding modes used for _mm_round_ps etc. can be translated to the generic equivalents:

switch (N->getOpcode()) {
default: llvm_unreachable("Unexpected opcode!");
case ISD::STRICT_FCEIL:
case ISD::FCEIL: Imm = 0xA; break;
case ISD::STRICT_FFLOOR:
case ISD::FFLOOR: Imm = 0x9; break;
case ISD::STRICT_FTRUNC:
case ISD::FTRUNC: Imm = 0xB; break;
case ISD::STRICT_FROUNDEVEN:
case ISD::FROUNDEVEN: Imm = 0x8; break;
case ISD::STRICT_FNEARBYINT:
case ISD::FNEARBYINT: Imm = 0xC; break;
case ISD::STRICT_FRINT:
case ISD::FRINT: Imm = 0x4; break;
}

We should be trying to convert these to the ceil/floor/trunc/roundeven/nearbyint/rint intrinsics (either regular or strict/constrained depending on fp strict mode).

The scalar cases are a bit trickier requiring extraction/insertion.

I don't expect AVX512 rndscale equivalents to be fully handled in this patch, which can be messier to deal with.

Metadata

Metadata

Assignees

Labels

backend:X86clang:frontendLanguage frontend issues, e.g. anything involving "Sema"good first issuehttps://github.com/llvm/llvm-project/contribute

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions