[all-commits] [llvm/llvm-project] cea170: [ConstantTime] Fix CT_SELECT expansion to preserve...

Julius Alexandre via All-commits all-commits at lists.llvm.org
Sat Mar 7 13:23:28 PST 2026


  Branch: refs/heads/users/wizardengineer/ct-select-core
  Home:   https://github.com/llvm/llvm-project
  Commit: cea17086440ee6deb04d8b2461812dc86423434b
      https://github.com/llvm/llvm-project/commit/cea17086440ee6deb04d8b2461812dc86423434b
  Author: wizardengineer <juliuswoosebert at gmail.com>
  Date:   2026-03-07 (Sat, 07 Mar 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.



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