[all-commits] [llvm/llvm-project] ff2bc5: [ConstantTime][LLVM] Add llvm.ct.select intrinsic ...
Akshay K via All-commits
all-commits at lists.llvm.org
Fri Aug 7 10:11:19 PDT 2026
Branch: refs/heads/users/wizardengineer/ct-select-core
Home: https://github.com/llvm/llvm-project
Commit: ff2bc54e0a24f7f57506fa57e162c05b296dfb5a
https://github.com/llvm/llvm-project/commit/ff2bc54e0a24f7f57506fa57e162c05b296dfb5a
Author: wizardengineer <juliuswoosebert at gmail.com>
Date: 2026-08-07 (Fri, 07 Aug 2026)
Changed paths:
M llvm/include/llvm/CodeGen/ISDOpcodes.h
M llvm/include/llvm/CodeGen/SelectionDAG.h
M llvm/include/llvm/CodeGen/TargetLowering.h
M llvm/include/llvm/IR/Intrinsics.td
M llvm/include/llvm/Target/TargetSelectionDAG.td
M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
M llvm/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
M llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
M llvm/lib/Target/AArch64/AArch64ISelLowering.h
M llvm/lib/Target/ARM/ARMISelLowering.h
M llvm/lib/Target/X86/X86ISelLowering.h
A llvm/test/CodeGen/RISCV/ctselect-fallback.ll
A llvm/test/CodeGen/X86/ctselect.ll
Log Message:
-----------
[ConstantTime][LLVM] Add llvm.ct.select intrinsic with generic SelectionDAG lowering
[LLVM][CodeGen] Improve CTSELECT fallback lowering and target support modeling (#179395)
This pull request refactors and improves the **fallback handling** of
constant-time select (CTSELECT) in LLVM’s code generation
infrastructure. The changes clarify semantics, simplify
target-capability checks, and improve the correctness and
maintainability of fallback lowering, without changing the intended
constant-time guarantees.
- **CTSELECT semantics**
- Clarified documentation for the `CTSELECT` node to explicitly describe
its operands and its role as the lowering target for the constant-time
select intrinsic.
- **TargetLowering cleanup**
- Removed CTSELECT-specific entries from `SelectSupportKind`.
- Introduced a dedicated `isCtSelectSupported(EVT)` hook to cleanly
separate ISA select support from constant-time guarantees.
- Updated intrinsic lowering to use this new capability check.
- **Fallback implementation improvements**
- Updated the generic SelectionDAG fallback lowering to use the
canonical bitwise formulation:
```
F ^ ((T ^ F) & Mask)
```
- Simplified handling of vector splats and bitcasting in the fallback
path.
- **DAGCombiner refactor**
- Renamed and clarified CTSELECT-related DAGCombiner code paths for
improved readability.
- **Miscellaneous cleanups**
- Improved documentation headers for constant-time intrinsics.
- Removed unused flags and minor nits uncovered during review.
These changes primarily affect the **generic fallback path** used when
targets do not provide specialized CTSELECT lowering. Target-specific
implementations are handled in follow-up PRs
Commit: 34b445e09fa581855a8f787cba08d588d43b4db2
https://github.com/llvm/llvm-project/commit/34b445e09fa581855a8f787cba08d588d43b4db2
Author: wizardengineer <juliuswoosebert at gmail.com>
Date: 2026-08-07 (Fri, 07 Aug 2026)
Changed paths:
M llvm/include/llvm/CodeGen/ISDOpcodes.h
M llvm/include/llvm/CodeGen/SelectionDAG.h
M llvm/include/llvm/CodeGen/TargetLowering.h
M llvm/include/llvm/Target/TargetSelectionDAG.td
M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
M llvm/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
M llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
M llvm/lib/CodeGen/TargetLoweringBase.cpp
M llvm/lib/Target/AArch64/AArch64ISelLowering.h
M llvm/lib/Target/ARM/ARMISelLowering.h
M llvm/lib/Target/X86/X86ISelLowering.h
M llvm/test/CodeGen/RISCV/ctselect-fallback.ll
M llvm/test/CodeGen/X86/ctselect.ll
Log Message:
-----------
[ConstantTime] Changed CTSELECT instances to CT_SELECT
Commit: fc6ab3e8aa4ea71a135ba25b5bd7558dce05327a
https://github.com/llvm/llvm-project/commit/fc6ab3e8aa4ea71a135ba25b5bd7558dce05327a
Author: wizardengineer <juliuswoosebert at gmail.com>
Date: 2026-08-07 (Fri, 07 Aug 2026)
Changed paths:
M llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
M llvm/test/CodeGen/RISCV/ctselect-fallback.ll
M llvm/test/CodeGen/X86/ctselect.ll
Log Message:
-----------
[ConstantTime] Fix CT_SELECT expansion to preserve constant-time guarantees
Create CT_SELECT nodes for scalar types regardless of target support, so
they survive DAGCombiner (visitCT_SELECT is conservative). Expand to
AND/OR/XOR during operation legalization after SETCC is lowered, preventing
the sext(setcc)->select fold chain that converts constant-time patterns
into data-dependent conditional moves (e.g. movn/movz on MIPS).
The mask uses SUB(0, AND(Cond, 1)) instead of SIGN_EXTEND because type
legalization already promoted i1 to the SetCC result type, making
SIGN_EXTEND a no-op for same-width types.
Commit: 17974f99174898a6ecc8f9ae943987f20a527347
https://github.com/llvm/llvm-project/commit/17974f99174898a6ecc8f9ae943987f20a527347
Author: AkshayK <iit.akshay at gmail.com>
Date: 2026-08-07 (Fri, 07 Aug 2026)
Changed paths:
M llvm/include/llvm/Target/TargetSelectionDAG.td
M llvm/lib/Analysis/InstructionSimplify.cpp
M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
M llvm/test/CodeGen/RISCV/ctselect-fallback.ll
M llvm/test/CodeGen/X86/ctselect.ll
A llvm/test/Transforms/InstSimplify/ct-select.ll
Log Message:
-----------
[ConstantTime] Move ct.select lowering to legalizer; misc fixes
- LegalizeDAG owns CT_SELECT lowering: scalar-mask+splat for vectors
(avoids illegal vNi1), memory-blend for FP types lacking a legal
same-size integer (f64 on i386 no-SSE, fp128, x86_fp80)
- Add InstSimplify folds for constant cond and identical arms
- Extend X86 tests to half/bfloat/fp128/x86_fp80; nounwind cleanup
- Preserve flags through legalizer; reuse SDTSelect
Commit: 055410299711b62c67791735aa6f853ee3fde7e4
https://github.com/llvm/llvm-project/commit/055410299711b62c67791735aa6f853ee3fde7e4
Author: AkshayK <iit.akshay at gmail.com>
Date: 2026-08-07 (Fri, 07 Aug 2026)
Changed paths:
M llvm/include/llvm/CodeGen/ISDOpcodes.h
M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Log Message:
-----------
[ConstantTime] Reword comments and LangRef doc
Commit: 730c2493a2b654b427f20fd6e3d485ada648a590
https://github.com/llvm/llvm-project/commit/730c2493a2b654b427f20fd6e3d485ada648a590
Author: AkshayK <iit.akshay at gmail.com>
Date: 2026-08-07 (Fri, 07 Aug 2026)
Changed paths:
M llvm/docs/LangRef.md
M llvm/include/llvm/CodeGen/ISDOpcodes.h
M llvm/include/llvm/CodeGen/SelectionDAG.h
M llvm/include/llvm/IR/Intrinsics.td
M llvm/include/llvm/Target/TargetSelectionDAG.td
M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
M llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
M llvm/test/CodeGen/RISCV/ctselect-fallback.ll
M llvm/test/CodeGen/X86/ctselect.ll
Log Message:
-----------
[ConstantTime] Address reviewer feedback for llvm.ct.select core
Model llvm.ct.select as IntrInaccessibleMemOnly so the call stays pinned
without pessimizing alias analysis. Make CT_SELECT flagless (drop the
getCTSelect flags parameter, dead flag propagation, and
setFlags-after-getNode) and assert its condition is scalar. Blend the FP
memory fallback at the widest legal integer width with ext-load and
trunc-store tails instead of illegal i8 chunks. Restore the LangRef
section dropped in the rebase onto the Markdown docs migration and note
RISC-V Zkt/Zvkt. Apply review style fixes and regenerate affected tests.
Commit: e8f8ca554f8fe1e60226f7119c933b2673ebe4f2
https://github.com/llvm/llvm-project/commit/e8f8ca554f8fe1e60226f7119c933b2673ebe4f2
Author: AkshayK <iit.akshay at gmail.com>
Date: 2026-08-07 (Fri, 07 Aug 2026)
Changed paths:
M llvm/docs/LangRef.md
M llvm/include/llvm/CodeGen/SelectionDAG.h
M llvm/include/llvm/IR/Intrinsics.td
M llvm/lib/Analysis/InstructionSimplify.cpp
M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
M llvm/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
M llvm/lib/IR/Verifier.cpp
A llvm/test/CodeGen/RISCV/ctselect-fallback-gisel.ll
A llvm/test/CodeGen/RISCV/ctselect-fallback-scalable.ll
M llvm/test/CodeGen/X86/ctselect.ll
A llvm/test/Verifier/ct-select.ll
Log Message:
-----------
[ConstantTime] Apply review fixes for llvm.ct.select core
- Verifier: reject aggregate types instead of crashing ISel; add test.
- Fix scalable-vector expansion crash when the element type is not a
legal scalar; add RVV test.
- LangRef: document poison/undef, noundef, permitted folds, and FMF
behavior; rewrite Syntax/Overview.
- Deduplicate CT_SELECT type-legalizer handlers into the SELECT paths.
- Misc: FP int-twin assert, dead null check, in-place memory blend,
flag-free PromoteNode, GlobalISel fallback test, comment cleanups.
Compare: https://github.com/llvm/llvm-project/compare/f4383a332170...e8f8ca554f8f
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list