Skip to content

P4324 - #8

Merged
cor3ntin merged 0 commit into
cppalliance:p4324from
cor3ntin:p4324
Aug 21, 2026
Merged

P4324#8
cor3ntin merged 0 commit into
cppalliance:p4324from
cor3ntin:p4324

Conversation

@cor3ntin

@cor3ntin cor3ntin commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Implement https://isocpp.org/files/papers/D4324R0.html

Some difference

  • no assumable field
  • is_ignored/constify need to be consteval

This also rebases the contract work from Eric on top of llvm main.

Most of the work using opus 5.

@cor3ntin

Copy link
Copy Markdown
Collaborator Author

code there https://github.com/cor3ntin/llvm-project/tree/p4324

@sdkrystian @vinniefalco Maybe we can update main in this repo ? That would make the pr less insane!

@cor3ntin
cor3ntin merged commit c0d0594 into cppalliance:p4324 Aug 21, 2026
cor3ntin pushed a commit that referenced this pull request Aug 21, 2026
…lvm#212759)

I see the following 

```
 anutosh491@Anutoshs-MacBook-Air llvm-project % cat /private/tmp/wasm-scalable-shift-cost.ll
define <vscale x 4 x i32> @shift(<vscale x 4 x i32> %x,
                                 <vscale x 4 x i32> %amount) {
  %result = shl <vscale x 4 x i32> %x, %amount
  ret <vscale x 4 x i32> %result
}


 anutosh491@Anutoshs-MacBook-Air llvm-project % build-assert/bin/opt \
  -mtriple=wasm32-unknown-unknown \
  -mattr=+simd128 \
  -passes='print<cost-model>' \
  -disable-output \
  /private/tmp/wasm-scalable-shift-cost.ll
Printing analysis 'Cost Model Analysis' for function 'shift':
Cost Model: Assertion failed: (isa<To>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file Casting.h, line 572.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.      Program arguments: build-assert/bin/opt -mtriple=wasm32-unknown-unknown -mattr=+simd128 -passes=print<cost-model> -disable-output /private/tmp/wasm-scalable-shift-cost.ll
1.      Running pass "function(print<cost-model>)" on module "/private/tmp/wasm-scalable-shift-cost.ll"
2.      Running pass "print<cost-model>" on function "shift"
 #0 0x0000000105b7a56c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/anutosh491/work/llvm-project/build-assert/bin/opt+0x102f6256c)
 #1 0x0000000105b78248 llvm::sys::RunSignalHandlers() (/Users/anutosh491/work/llvm-project/build-assert/bin/opt+0x102f60248)
 #2 0x0000000105b7b170 SignalHandler(int, __siginfo*, void*) (/Users/anutosh491/work/llvm-project/build-assert/bin/opt+0x102f63170)
 #3 0x000000018b5f7744 (/usr/lib/system/libsystem_platform.dylib+0x1804fb744)
 #4 0x000000018b5ed8d8 (/usr/lib/system/libsystem_pthread.dylib+0x1804f18d8)
 #5 0x000000018b4f4644 (/usr/lib/system/libsystem_c.dylib+0x1803f8644)
 #6 0x000000018b4f38a0 (/usr/lib/system/libsystem_c.dylib+0x1803f78a0)
 #7 0x0000000104036ddc llvm::BasicTTIImplBase<llvm::WebAssemblyTTIImpl>::getArithmeticInstrCost(unsigned int, llvm::Type*, llvm::TargetTransformInfo::TargetCostKind, llvm::TargetTransformInfo::OperandValueInfo, llvm::TargetTransformInfo::OperandValueInfo, llvm::ArrayRef<llvm::Value const*>, llvm::Instruction const*) const (/Users/anutosh491/work/llvm-project/build-assert/bin/opt+0x10141eddc)
 #8 0x000000010403b0ac llvm::TargetTransformInfoImplCRTPBase<llvm::WebAssemblyTTIImpl>::getInstructionCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>, llvm::TargetTransformInfo::TargetCostKind) const (/Users/anutosh491/work/llvm-project/build-assert/bin/opt+0x1014230ac)
 llvm#9 0x00000001049162c8 llvm::TargetTransformInfo::getInstructionCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>, llvm::TargetTransformInfo::TargetCostKind) const (/Users/anutosh491/work/llvm-project/build-assert/bin/opt+0x101cfe2c8)
llvm#10 0x00000001058d90b4 llvm::TargetTransformInfo::getInstructionCost(llvm::User const*, llvm::TargetTransformInfo::TargetCostKind) const (/Users/anutosh491/work/llvm-project/build-assert/bin/opt+0x102cc10b4)
llvm#11 0x000000010468a368 getCost(llvm::Instruction&, llvm::TargetTransformInfo::TargetCostKind, llvm::TargetTransformInfo&) (/Users/anutosh491/work/llvm-project/build-assert/bin/opt+0x101a72368)
llvm#12 0x0000000104689dd4 llvm::CostModelPrinterPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/Users/anutosh491/work/llvm-project/build-assert/bin/opt+0x101a71dd4)
llvm#13 0x0000000105186554 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/Users/anutosh491/work/llvm-project/build-assert/bin/opt+0x10256e554)
llvm#14 0x000000010518a680 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/Users/anutosh491/work/llvm-project/build-assert/bin/opt+0x102572680)
llvm#15 0x0000000105185418 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/Users/anutosh491/work/llvm-project/build-assert/bin/opt+0x10256d418)
llvm#16 0x0000000106127cb0 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::__1::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/Users/anutosh491/work/llvm-project/build-assert/bin/opt+0x10350fcb0)
llvm#17 0x0000000106131eac optMain (/Users/anutosh491/work/llvm-project/build-assert/bin/opt+0x103519eac)
llvm#18 0x000000018b22fe00
zsh: abort      build-assert/bin/opt -mtriple=wasm32-unknown-unknown -mattr=+simd128 
```
cor3ntin pushed a commit that referenced this pull request Aug 21, 2026
…10793)

A shuffle mask that interleaves zeros between every other byte element
is equivalent to a vector shift left on a wider element type. This
avoids generating a `tbl` instruction with a constant mask loaded from
memory, replacing it with a single `shl` instruction.

Before:
```asm
adrp  x8, .LCPI0_0
ldr   q1, [x8, :lo12:.LCPI0_0]
tbl   v0.16b, { v0.16b }, v1.16b
```

After:
```asm
shl   v0.8h, v0.8h, #8
```

Both `<16 x i8>` and `<8 x i8>` vectors are handled. The canonicalized
form where zeros appear in either the first or second shuffle operand is
also handled.

Fixes llvm#107287
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.

1 participant