Commit 990cbc4
committed
[CIR][X86] Implement lowering for sqrt builtins
Implements CIR IR generation for X86 sqrt builtin functions, addressing issue #167765.
This change adds support for lowering the following X86 sqrt builtins to CIR operations:
- __builtin_ia32_sqrtps (128-bit float vector sqrt)
- __builtin_ia32_sqrtps256 (256-bit float vector sqrt)
- __builtin_ia32_sqrtps512 (512-bit float vector sqrt)
- __builtin_ia32_sqrtpd (128-bit double vector sqrt)
- __builtin_ia32_sqrtpd256 (256-bit double vector sqrt)
- __builtin_ia32_sqrtpd512 (512-bit double vector sqrt)
- __builtin_ia32_sqrtph, __builtin_ia32_sqrtph256, __builtin_ia32_sqrtph512 (half precision)
- __builtin_ia32_vsqrtbf16, __builtin_ia32_vsqrtbf16256, __builtin_ia32_vsqrtbf16512 (bfloat16)
- __builtin_ia32_sqrtsh_round_mask, __builtin_ia32_sqrtsd_round_mask, __builtin_ia32_sqrtss_round_mask (masked rounding)
Changes:
- Added CIROps.h wrapper header for CIR operation declarations
- Updated CIROps.td with SqrtOp definition (Pure trait, type-safe constraints)
- Updated CIRTypeConstraints.td with float type constraints
- Implemented builtin handling in CIRGenBuiltinX86.cpp
- Added SqrtOp verification in CIRDialect.cpp
- Implemented cir.sqrt lowering to llvm.sqrt.* intrinsics in LowerToLLVM.cpp/h
- Added comprehensive test coverage:
* cir-sqrtps-builtins.c: X86 builtin tests (128/256/512-bit variants)
* sqrt-lowering.mlir: CIR to LLVM IR lowering tests (scalar and vector)
The implementation follows existing CIR patterns and generates proper cir.sqrt operations
for all sqrt builtin variants with appropriate type checking and lowering to LLVM IR.
Related: #1677651 parent 83f8a19 commit 990cbc4
File tree
5 files changed
+73
-42
lines changed- clang
- include/clang/CIR/Dialect/IR
- test/CIR
- CodeGen/X86
5 files changed
+73
-42
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
This file was deleted.
This file was deleted.
This file was deleted.
0 commit comments