Skip to content

Comments

[WebAssembly] Fold constant i8x16.swizzle and i8x16.relaxed.swizzle to shufflevector#169110

Merged
dschuff merged 6 commits intollvm:mainfrom
valadaptive:wasm-swizzle-const
Jan 8, 2026
Merged

[WebAssembly] Fold constant i8x16.swizzle and i8x16.relaxed.swizzle to shufflevector#169110
dschuff merged 6 commits intollvm:mainfrom
valadaptive:wasm-swizzle-const

Conversation

@valadaptive
Copy link
Contributor

@valadaptive valadaptive commented Nov 21, 2025

Resolves #169058.

This adds an InstCombine pass a TTI hook to the WebAssembly backend that folds i8x16.swizzle and i8x16.relaxed.swizzle operations to shufflevector operations if their mask operands are constant.

This is mainly useful for abstractions over the raw intrinsics--for instance, in architecture-generic SIMD code that may not be able to expose the constant shuffles due to type system limitations.

I took most of this from the x86 backend (in particular, simplifyX86vpermilvar in X86InstCombineIntrinsic), and adapted it for the WebAssembly backend. There wasn't any previous instCombineIntrinsic method on the WebAssembly TargetTransformInfo, so I added it. Right now, this swizzle optimization is the only one it performs.

As I noted in the transform itself, the "relaxed" swizzle actually has stricter preconditions than the non-relaxed one. If a non-negative but still out-of-bounds index is provided, the "relaxed" swizzle can choose between returning 0 and the lane at the index modulo 16. However, it must make the same choice every time, and we don't know which choice the runtime will make, so we can't constant-fold it.

The regression tests were mostly generated by Claude and adapted a bit by me (I tried to follow the InstCombine contributor guide). There was previously no WebAssembly subdirectory within the InstCombine tests, so I created that too; as of now, the swizzle fold test is the only file in it. Everything else was written by myself (well, partly copy-pasted from the x86 backend).

I'm not sure how to write an Alive2 test for this; I can't find any examples where the input is an arbitrary constant.

@github-actions
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added backend:WebAssembly llvm:instcombine Covers the InstCombine, InstSimplify and AggressiveInstCombine passes llvm:transforms labels Nov 21, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 21, 2025

@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-backend-webassembly

Author: None (valadaptive)

Changes

Resolves #169058.

This adds an InstCombine pass to the WebAssembly backend that folds i8x16.swizzle and i8x16.relaxed.swizzle operations to shufflevector operations if their mask operands are constant.

This is mainly useful for abstractions over the raw intrinsics--for instance, in architecture-generic SIMD code that may not be able to expose the constant shuffles due to type system limitations.

I took most of this from the x86 backend (in particular, simplifyX86vpermilvar in X86InstCombineIntrinsic), and adapted it for the WebAssembly backend. There wasn't any previous instCombineIntrinsic method on the WebAssembly TargetTransformInfo, so I added it. Right now, this swizzle optimization is the only one it performs.

As I noted in the transform itself, the "relaxed" swizzle actually has stricter preconditions than the non-relaxed one. If a non-negative but still out-of-bounds index is provided, the "relaxed" swizzle can choose between returning 0 and the lane at the index modulo 16. However, it must make the same choice every time, and we don't know which choice the runtime will make, so we can't constant-fold it.

The regression tests were mostly generated by Claude and adapted a bit by me (I tried to follow the InstCombine contributor guide). There was previously no WebAssembly subdirectory within the InstCombine tests, so I created that too; as of now, the swizzle fold test is the only file in it. Everything else was written by myself (well, partly copy-pasted from the x86 backend).

I'm not sure how to write an Alive2 test for this; I can't find any examples where the input is an arbitrary constant.


Full diff: https://github.com/llvm/llvm-project/pull/169110.diff

5 Files Affected:

  • (modified) llvm/lib/Target/WebAssembly/CMakeLists.txt (+1)
  • (added) llvm/lib/Target/WebAssembly/WebAssemblyInstCombineIntrinsic.cpp (+107)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.h (+2)
  • (added) llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll (+116)
  • (modified) llvm/utils/gn/secondary/llvm/lib/Target/WebAssembly/BUILD.gn (+1)
diff --git a/llvm/lib/Target/WebAssembly/CMakeLists.txt b/llvm/lib/Target/WebAssembly/CMakeLists.txt
index 17df119d62709..13fff96fc6a33 100644
--- a/llvm/lib/Target/WebAssembly/CMakeLists.txt
+++ b/llvm/lib/Target/WebAssembly/CMakeLists.txt
@@ -32,6 +32,7 @@ add_llvm_target(WebAssemblyCodeGen
   WebAssemblyFixIrreducibleControlFlow.cpp
   WebAssemblyFixFunctionBitcasts.cpp
   WebAssemblyFrameLowering.cpp
+  WebAssemblyInstCombineIntrinsic.cpp
   WebAssemblyISelDAGToDAG.cpp
   WebAssemblyISelLowering.cpp
   WebAssemblyInstrInfo.cpp
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstCombineIntrinsic.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyInstCombineIntrinsic.cpp
new file mode 100644
index 0000000000000..2fa00b3c5d50d
--- /dev/null
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstCombineIntrinsic.cpp
@@ -0,0 +1,107 @@
+//=== WebAssemblyInstCombineIntrinsic.cpp -
+//                                WebAssembly specific InstCombine pass ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file implements a TargetTransformInfo analysis pass specific to
+/// WebAssembly. It uses the target's detailed information to provide more
+/// precise answers to certain TTI queries, while letting the target independent
+/// and default TTI implementations handle the rest.
+///
+//===----------------------------------------------------------------------===//
+
+#include "WebAssemblyTargetTransformInfo.h"
+#include "llvm/IR/IntrinsicInst.h"
+#include "llvm/IR/IntrinsicsWebAssembly.h"
+#include "llvm/Transforms/InstCombine/InstCombiner.h"
+#include <optional>
+
+using namespace llvm;
+using namespace llvm::PatternMatch;
+
+/// Attempt to convert [relaxed_]swizzle to shufflevector if the mask is
+/// constant.
+static Value *simplifyWasmSwizzle(const IntrinsicInst &II,
+                                  InstCombiner::BuilderTy &Builder,
+                                  bool IsRelaxed) {
+  auto *V = dyn_cast<Constant>(II.getArgOperand(1));
+  if (!V)
+    return nullptr;
+
+  auto *VecTy = cast<FixedVectorType>(II.getType());
+  unsigned NumElts = VecTy->getNumElements();
+  assert(NumElts == 16);
+
+  // Construct a shuffle mask from constant integers or UNDEFs.
+  int Indexes[16];
+  bool AnyOutOfBounds = false;
+
+  for (unsigned I = 0; I < NumElts; ++I) {
+    Constant *COp = V->getAggregateElement(I);
+    if (!COp || (!isa<UndefValue>(COp) && !isa<ConstantInt>(COp)))
+      return nullptr;
+
+    if (isa<UndefValue>(COp)) {
+      Indexes[I] = -1;
+      continue;
+    }
+
+    int64_t Index = cast<ConstantInt>(COp)->getSExtValue();
+
+    if (Index >= NumElts && IsRelaxed) {
+      // For lane indices above 15, the relaxed_swizzle operation can choose
+      // between returning 0 or the lane at `Index % 16`. However, the choice
+      // must be made consistently. As the WebAssembly spec states:
+      //
+      // "The result of relaxed operators are implementation-dependent, because
+      // the set of possible results may depend on properties of the host
+      // environment, such as its hardware. Technically, their behaviour is
+      // controlled by a set of global parameters to the semantics that an
+      // implementation can instantiate in different ways. These choices are
+      // fixed, that is, parameters are constant during the execution of any
+      // given program."
+      //
+      // The WebAssembly runtime may choose differently from us, so we can't
+      // optimize a relaxed swizzle with lane indices above 15.
+      return nullptr;
+    }
+
+    if (Index >= NumElts || Index < 0) {
+      AnyOutOfBounds = true;
+      // If there are out-of-bounds indices, the swizzle instruction returns
+      // zeroes in those lanes. We'll provide an all-zeroes vector as the
+      // second argument to shufflevector and read the first element from it.
+      Indexes[I] = NumElts;
+      continue;
+    }
+
+    Indexes[I] = Index;
+  }
+
+  auto *V1 = II.getArgOperand(0);
+  auto *V2 =
+      AnyOutOfBounds ? Constant::getNullValue(VecTy) : PoisonValue::get(VecTy);
+
+  return Builder.CreateShuffleVector(V1, V2, ArrayRef(Indexes, NumElts));
+}
+
+std::optional<Instruction *>
+WebAssemblyTTIImpl::instCombineIntrinsic(InstCombiner &IC,
+                                         IntrinsicInst &II) const {
+  Intrinsic::ID IID = II.getIntrinsicID();
+  switch (IID) {
+  case Intrinsic::wasm_swizzle:
+  case Intrinsic::wasm_relaxed_swizzle:
+    if (Value *V = simplifyWasmSwizzle(
+            II, IC.Builder, IID == Intrinsic::wasm_relaxed_swizzle)) {
+      return IC.replaceInstUsesWith(II, V);
+    }
+    break;
+  }
+
+  return std::nullopt;
+}
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.h b/llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.h
index 4146c0ec6ab07..11f7efc625399 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.h
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.h
@@ -90,6 +90,8 @@ class WebAssemblyTTIImpl final : public BasicTTIImplBase<WebAssemblyTTIImpl> {
                                      TTI::TargetCostKind CostKind,
                                      unsigned Index, const Value *Op0,
                                      const Value *Op1) const override;
+  std::optional<Instruction *>
+  instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const override;
   InstructionCost getPartialReductionCost(
       unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,
       ElementCount VF, TTI::PartialReductionExtendKind OpAExtend,
diff --git a/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll b/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
new file mode 100644
index 0000000000000..ba251929c3739
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
@@ -0,0 +1,116 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
+; RUN: opt < %s -passes=instcombine -mtriple=wasm32-unknown-unknown -S | FileCheck %s
+
+; swizzle with a constant operand should be optimized to a shufflevector.
+
+declare <16 x i8> @llvm.wasm.swizzle(<16 x i8>, <16 x i8>)
+declare <16 x i8> @llvm.wasm.relaxed.swizzle(<16 x i8>, <16 x i8>)
+
+; Identity swizzle pattern
+define <16 x i8> @swizzle_identity(<16 x i8> %v) {
+; CHECK-LABEL: define <16 x i8> @swizzle_identity(
+; CHECK-SAME: <16 x i8> [[V:%.*]]) {
+; CHECK-NEXT:    ret <16 x i8> [[V]]
+;
+  %result = tail call <16 x i8> @llvm.wasm.swizzle(<16 x i8> %v, <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>)
+  ret <16 x i8> %result
+}
+
+; Reverse swizzle pattern
+define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
+; CHECK-LABEL: define <16 x i8> @swizzle_reverse(
+; CHECK-SAME: <16 x i8> [[V:%.*]]) {
+; CHECK-NEXT:    [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
+; CHECK-NEXT:    ret <16 x i8> [[RESULT]]
+;
+  %result = tail call <16 x i8> @llvm.wasm.swizzle(<16 x i8> %v, <16 x i8> <i8 15, i8 14, i8 13, i8 12, i8 11, i8 10, i8 9, i8 8, i8 7, i8 6, i8 5, i8 4, i8 3, i8 2, i8 1, i8 0>)
+  ret <16 x i8> %result
+}
+
+; undef elements
+define <16 x i8> @swizzle_with_undef(<16 x i8> %v) {
+; CHECK-LABEL: define <16 x i8> @swizzle_with_undef(
+; CHECK-SAME: <16 x i8> [[V:%.*]]) {
+; CHECK-NEXT:    [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
+; CHECK-NEXT:    ret <16 x i8> [[RESULT]]
+;
+  %result = tail call <16 x i8> @llvm.wasm.swizzle(<16 x i8> %v, <16 x i8> <i8 0, i8 undef, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>)
+  ret <16 x i8> %result
+}
+
+; Negative test: non-constant operand
+define <16 x i8> @swizzle_non_constant(<16 x i8> %v, <16 x i8> %mask) {
+; CHECK-LABEL: define <16 x i8> @swizzle_non_constant(
+; CHECK-SAME: <16 x i8> [[V:%.*]], <16 x i8> [[MASK:%.*]]) {
+; CHECK-NEXT:    [[RESULT:%.*]] = tail call <16 x i8> @llvm.wasm.swizzle(<16 x i8> [[V]], <16 x i8> [[MASK]])
+; CHECK-NEXT:    ret <16 x i8> [[RESULT]]
+;
+  %result = tail call <16 x i8> @llvm.wasm.swizzle(<16 x i8> %v, <16 x i8> %mask)
+  ret <16 x i8> %result
+}
+
+; Out-of-bounds index, otherwise identity pattern
+define <16 x i8> @swizzle_out_of_bounds_1(<16 x i8> %v) {
+; CHECK-LABEL: define <16 x i8> @swizzle_out_of_bounds_1(
+; CHECK-SAME: <16 x i8> [[V:%.*]]) {
+; CHECK-NEXT:    [[RESULT:%.*]] = insertelement <16 x i8> [[V]], i8 0, i64 15
+; CHECK-NEXT:    ret <16 x i8> [[RESULT]]
+;
+  %result = tail call <16 x i8> @llvm.wasm.swizzle(<16 x i8> %v, <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 16>)
+  ret <16 x i8> %result
+}
+
+; Out-of-bounds indices, both negative and positive
+define <16 x i8> @swizzle_out_of_bounds_2(<16 x i8> %v) {
+; CHECK-LABEL: define <16 x i8> @swizzle_out_of_bounds_2(
+; CHECK-SAME: <16 x i8> [[V:%.*]]) {
+; CHECK-NEXT:    [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> <i8 0, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison>, <16 x i32> <i32 16, i32 16, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
+; CHECK-NEXT:    ret <16 x i8> [[RESULT]]
+;
+  %result = tail call <16 x i8> @llvm.wasm.swizzle(<16 x i8> %v, <16 x i8> <i8 99, i8 -1, i8 13, i8 12, i8 11, i8 10, i8 9, i8 8, i8 7, i8 6, i8 5, i8 4, i8 3, i8 2, i8 1, i8 0>)
+  ret <16 x i8> %result
+}
+
+; Identity swizzle pattern (relaxed_swizzle)
+define <16 x i8> @relaxed_swizzle_identity(<16 x i8> %v) {
+; CHECK-LABEL: define <16 x i8> @relaxed_swizzle_identity(
+; CHECK-SAME: <16 x i8> [[V:%.*]]) {
+; CHECK-NEXT:    ret <16 x i8> [[V]]
+;
+  %result = tail call <16 x i8> @llvm.wasm.relaxed.swizzle(<16 x i8> %v, <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>)
+  ret <16 x i8> %result
+}
+
+; Reverse swizzle pattern (relaxed_swizzle)
+define <16 x i8> @relaxed_swizzle_reverse(<16 x i8> %v) {
+; CHECK-LABEL: define <16 x i8> @relaxed_swizzle_reverse(
+; CHECK-SAME: <16 x i8> [[V:%.*]]) {
+; CHECK-NEXT:    [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
+; CHECK-NEXT:    ret <16 x i8> [[RESULT]]
+;
+  %result = tail call <16 x i8> @llvm.wasm.relaxed.swizzle(<16 x i8> %v, <16 x i8> <i8 15, i8 14, i8 13, i8 12, i8 11, i8 10, i8 9, i8 8, i8 7, i8 6, i8 5, i8 4, i8 3, i8 2, i8 1, i8 0>)
+  ret <16 x i8> %result
+}
+
+; Out-of-bounds index, only negative (relaxed_swizzle)
+define <16 x i8> @relaxed_swizzle_out_of_bounds(<16 x i8> %v) {
+; CHECK-LABEL: define <16 x i8> @relaxed_swizzle_out_of_bounds(
+; CHECK-SAME: <16 x i8> [[V:%.*]]) {
+; CHECK-NEXT:    [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> <i8 0, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison>, <16 x i32> <i32 16, i32 16, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
+; CHECK-NEXT:    ret <16 x i8> [[RESULT]]
+;
+  %result = tail call <16 x i8> @llvm.wasm.relaxed.swizzle(<16 x i8> %v, <16 x i8> <i8 -99, i8 -1, i8 13, i8 12, i8 11, i8 10, i8 9, i8 8, i8 7, i8 6, i8 5, i8 4, i8 3, i8 2, i8 1, i8 0>)
+  ret <16 x i8> %result
+}
+
+; Negative test: out-of-bounds index, both positive and negative (relaxed_swizzle)
+; The choice between different relaxed semantics can only be made at runtime, since it must be consistent.
+define <16 x i8> @relaxed_swizzle_out_of_bounds_positive(<16 x i8> %v) {
+; CHECK-LABEL: define <16 x i8> @relaxed_swizzle_out_of_bounds_positive(
+; CHECK-SAME: <16 x i8> [[V:%.*]]) {
+; CHECK-NEXT:    [[RESULT:%.*]] = tail call <16 x i8> @llvm.wasm.relaxed.swizzle(<16 x i8> [[V]], <16 x i8> <i8 99, i8 -1, i8 13, i8 12, i8 11, i8 10, i8 9, i8 8, i8 7, i8 6, i8 5, i8 4, i8 3, i8 2, i8 1, i8 0>)
+; CHECK-NEXT:    ret <16 x i8> [[RESULT]]
+;
+  %result = tail call <16 x i8> @llvm.wasm.relaxed.swizzle(<16 x i8> %v, <16 x i8> <i8 99, i8 -1, i8 13, i8 12, i8 11, i8 10, i8 9, i8 8, i8 7, i8 6, i8 5, i8 4, i8 3, i8 2, i8 1, i8 0>)
+  ret <16 x i8> %result
+}
diff --git a/llvm/utils/gn/secondary/llvm/lib/Target/WebAssembly/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/Target/WebAssembly/BUILD.gn
index 11a57fcb008cd..8d976a33ce9db 100644
--- a/llvm/utils/gn/secondary/llvm/lib/Target/WebAssembly/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/Target/WebAssembly/BUILD.gn
@@ -54,6 +54,7 @@ static_library("LLVMWebAssemblyCodeGen") {
     "WebAssemblyFixFunctionBitcasts.cpp",
     "WebAssemblyFixIrreducibleControlFlow.cpp",
     "WebAssemblyFrameLowering.cpp",
+    "WebAssemblyInstCombineIntrinsic.cpp",
     "WebAssemblyISelDAGToDAG.cpp",
     "WebAssemblyISelLowering.cpp",
     "WebAssemblyInstrInfo.cpp",

@github-actions
Copy link

github-actions bot commented Nov 22, 2025

✅ With the latest revision this PR passed the undef deprecator.

@badumbatish
Copy link
Contributor

badumbatish commented Nov 22, 2025

thanks for the PR, looks really good to me, I think the code formatter is complaining about undef usages in one of the test, we can change it to poison for those.

Let's wait for another reviewer and for all the CI to pass to see if we miss anything. I'll hop in and out to enable CI/CD if there's any pushes

@github-actions
Copy link

github-actions bot commented Nov 22, 2025

🐧 Linux x64 Test Results

  • 186670 tests passed
  • 4890 tests skipped

@valadaptive
Copy link
Contributor Author

valadaptive commented Nov 22, 2025

Looking at the LangRef, I noticed:

A ‘poison’ value (described in the next section) should be used instead of ‘undef’ whenever possible. Poison values are stronger than undef, and enable more optimizations.

and

It is correct to replace a poison value with an undef value or any value of the type.

The swizzle optimization implemented here checks isa<UndefValue> for each element, which seems to also work for poison, and sets the corresponding shuffle index to -1 if so. I believe out-of-bounds swizzle elements become poison. A couple questions then:

  • Is isa<UndefValue> the correct thing to check? There are a lot more uses of isa<UndefValue> than isa<PoisonValue> in the codebase, and it's what the original x86 optimization uses.

  • Given that the LangRef says that poison is "stronger than undef", and that it is correct to replace a poison value with undef but not vice versa, is it correct to optimize an undef mask element in the input to a poison element in the output? The LangRef says:

    A poison element in the mask vector specifies that the resulting element is poison. For backwards-compatibility reasons, LLVM temporarily also accepts undef mask elements, which will be interpreted the same way as poison elements.

    But it's unclear if this means "an undef element specifies that the resulting element is undef", or "an undef element specifies that the resulting element is poison". (EDIT: Whoops, I read the literal next sentence. It's the former.)

    Again, this is the same behavior as the existing x86 permute optimization.

Copy link
Contributor

@ppenzin ppenzin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InstCombine guide also asks for alive2 proof, I believe. @topperc, you know more about instcombine than I do, is this right structure for a new instcombine pass?

Not sure what our position on Claude, though in this case it is just for the test.

@ppenzin ppenzin requested a review from topperc November 22, 2025 08:46
@valadaptive
Copy link
Contributor Author

InstCombine guide also asks for alive2 proof, I believe.

Is there a good guide for writing alive2 proofs? I'm not sure how to write a "for all arbitrary constants" constraint.

Copy link
Contributor

@lukel97 lukel97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to do this as a DAG combine and avoid adding a new pass

@valadaptive
Copy link
Contributor Author

Is it possible to do this as a DAG combine and avoid adding a new pass

My understanding is that DAG combine passes run much later in the pipeline, so we'd be losing out on a lot of optimizations if this was a DAG combine.

@lukel97
Copy link
Contributor

lukel97 commented Nov 24, 2025

Is it possible to do this as a DAG combine and avoid adding a new pass

My understanding is that DAG combine passes run much later in the pipeline, so we'd be losing out on a lot of optimizations if this was a DAG combine.

DAGCombiner has plenty of combines on shuffles so I don't think you'd miss much doing it there. But I'm just noticing now that this isn't actually a new pass, it's just implementing a TTI hook. Can you update the PR description to reflect that? I'm aware that the original comment in X86InstCombineIntrinsic.cpp says it's a pass but that probably needs updated.

@valadaptive
Copy link
Contributor Author

I've updated the PR description. I also noticed that for most other targets (except AMDGPU and x86), the instCombineIntrinsic hook is not a separate file, and is instead part of [target]TargetTransformInfo.cpp. Should I just move the new hook into WebAssemblyTargetTransformInfo.cpp?

@dschuff
Copy link
Member

dschuff commented Nov 24, 2025

I've updated the PR description. I also noticed that for most other targets (except AMDGPU and x86), the instCombineIntrinsic hook is not a separate file, and is instead part of [target]TargetTransformInfo.cpp. Should I just move the new hook into WebAssemblyTargetTransformInfo.cpp?

I think that would be fine. Both WebAssemblyTargetTransformInfo.cpp and your addition are pretty small, whereas for e.g. X86 they are pretty big.

@dschuff
Copy link
Member

dschuff commented Nov 24, 2025

Not sure what our position on Claude, though in this case it is just for the test.

General LLVM position is that it's fine, but that contributors are responsible for their contributions just as if they wrote it themselves. I think this PR is getting plenty of review so I'm not worried.

@valadaptive
Copy link
Contributor Author

I've moved the new TTI hook into WebAssemblyTargetTransformInfo.cpp.

I've decided to keep treating the swizzle indices as signed--the code is a lot cleaner that way, it's functionally equivalent since all valid indices are between 0 and 15, and finally I can't actually tell whether the spec treats them as signed or unsigned.

I'm still unsure about the following:

  • I'm handling undef values in this transform the same way that the x86 version does, but I don't know if that's correct.

  • If I can, I want to write an Alive2 proof for this transform, but I can't find any good guides on how to do so. In particular, I don't know if it supports "for all arbitrary constants" constraints.

Copy link
Member

@dschuff dschuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like all the feedback has been addressed. If @ppenzin doesn't have any more feedback, I think this looks good.

@@ -0,0 +1,116 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious: are these assertions actually generated by that script? I've not seen it generate the kind of regexes I see here (although I usually use the llc version). Or is this line just added by Claude? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what kind of regexes you're looking for. The CHECK lines do have regexes:

; CHECK-LABEL: define <16 x i8> @swizzle_reverse(
; CHECK-SAME: <16 x i8> [[V:%.*]]) {
; CHECK-NEXT:    [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
; CHECK-NEXT:    ret <16 x i8> [[RESULT]]

And yes, the CHECK lines were generated by that script. Just to double-check, I removed all the comments except for the RUN line, and re-ran ./llvm/utils/update_test_checks.py --opt-binary ./build/bin/opt llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll.

It generated the exact same CHECK lines with one exception: the regex in swizzle_out_of_bounds_1 names the result RESULT1 instead of just RESULT. If I regenerate the CHECK lines in the commit before adding the optimization, it goes back to being named RESULT, and therefore the CHECK lines are fully identical.

update_test_checks.py also did re-add the "Assertions have been autogenerated" comment.

I've since learned from other PRs that it's no longer necessary to include declarations for the intrinsics. I've updated the regression tests to use the freshly-regenerated swizzle_out_of_bounds_1 (in case it makes any difference) and removed the intrinsic declarations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I wasn't clear enough. I'm not looking for anything in particular, I was just curious about the behavior of the script, as I haven't seen the equivalent update_llc_test_checks.py script generate similar regexes, at least not for wasm. Mostly it just generates checks for the verbatim assembly text. It's nice that the LLVM IR version can do that 👍

@dschuff
Copy link
Member

dschuff commented Jan 8, 2026

I think we can go ahead and merge this, since it's been so long, there has been plenty of opportunity for followup (and there can always be post-commit review). Sorry for the delay.
Thanks for your work! Always nice to have more folks contributing.

@dschuff dschuff merged commit 8da7c05 into llvm:main Jan 8, 2026
9 of 10 checks passed
@github-actions
Copy link

github-actions bot commented Jan 8, 2026

@valadaptive Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

@llvm-ci
Copy link

llvm-ci commented Jan 8, 2026

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-sie-ubuntu-fast running on sie-linux-worker while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/144/builds/43503

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: Transforms/InstCombine/WebAssembly/fold-swizzle.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/opt < /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll -passes=instcombine -mtriple=wasm32-unknown-unknown -S | /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# executed command: /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/opt -passes=instcombine -mtriple=wasm32-unknown-unknown -S
# .---command stderr------------
# | /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/opt: WARNING: failed to create target machine for 'wasm32-unknown-unknown': unable to get target for 'wasm32-unknown-unknown', see --version and --triple.
# `-----------------------------
# executed command: /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# .---command stderr------------
# | �[1m/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:10:15: �[0m�[0;1;31merror: �[0m�[1mCHECK-NEXT: expected string not found in input
�[0m# | �[1m�[0m; CHECK-NEXT: ret <16 x i8> [[V]]
# | �[0;1;32m              ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:6:51: �[0m�[0;1;30mnote: �[0m�[1mscanning from here
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_identity(<16 x i8> %v) {
# | �[0;1;32m                                                  ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:6:51: �[0m�[0;1;30mnote: �[0m�[1mwith "V" equal to "%v"
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_identity(<16 x i8> %v) {
# | �[0;1;32m                                                  ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:8:2: �[0m�[0;1;30mnote: �[0m�[1mpossible intended match here
�[0m# | �[1m�[0m ret <16 x i8> %result
# | �[0;1;32m ^
�[0m# | �[0;1;32m�[0m�[1m/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:20:15: �[0m�[0;1;31merror: �[0m�[1mCHECK-NEXT: expected string not found in input
�[0m# | �[1m�[0m; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
# | �[0;1;32m              ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:11:50: �[0m�[0;1;30mnote: �[0m�[1mscanning from here
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# | �[0;1;32m                                                 ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:11:50: �[0m�[0;1;30mnote: �[0m�[1mwith "V" equal to "%v"
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# | �[0;1;32m                                                 ^
�[0m# | �[0;1;32m�[0m�[1m/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:31:15: �[0m�[0;1;31merror: �[0m�[1mCHECK-NEXT: expected string not found in input
�[0m# | �[1m�[0m; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
# | �[0;1;32m              ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:16:54: �[0m�[0;1;30mnote: �[0m�[1mscanning from here
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# | �[0;1;32m                                                     ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:16:54: �[0m�[0;1;30mnote: �[0m�[1mwith "V" equal to "%v"
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# | �[0;1;32m                                                     ^
�[0m# | �[0;1;32m�[0m�[1m/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:53:15: �[0m�[0;1;31merror: �[0m�[1mCHECK-NEXT: expected string not found in input
�[0m# | �[1m�[0m; CHECK-NEXT: [[RESULT1:%.*]] = insertelement <16 x i8> [[V]], i8 0, i64 15
# | �[0;1;32m              ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:26:58: �[0m�[0;1;30mnote: �[0m�[1mscanning from here
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_out_of_bounds_1(<16 x i8> %v) {
# | �[0;1;32m                                                         ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:26:58: �[0m�[0;1;30mnote: �[0m�[1mwith "V" equal to "%v"
...

@llvm-ci
Copy link

llvm-ci commented Jan 8, 2026

LLVM Buildbot has detected a new failure on builder clang-aarch64-quick running on linaro-clang-aarch64-quick while building llvm at step 5 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/65/builds/27869

Here is the relevant piece of the build log for the reference
Step 5 (ninja check 1) failure: stage 1 checked (failure)
******************** TEST 'LLVM :: Transforms/InstCombine/WebAssembly/fold-swizzle.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/opt < /home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll -passes=instcombine -mtriple=wasm32-unknown-unknown -S | /home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/FileCheck /home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# executed command: /home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/opt -passes=instcombine -mtriple=wasm32-unknown-unknown -S
# .---command stderr------------
# | /home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/opt: WARNING: failed to create target machine for 'wasm32-unknown-unknown': unable to get target for 'wasm32-unknown-unknown', see --version and --triple.
# `-----------------------------
# executed command: /home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/FileCheck /home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# .---command stderr------------
# | /home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:10:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: ret <16 x i8> [[V]]
# |               ^
# | <stdin>:6:51: note: scanning from here
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:6:51: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:8:2: note: possible intended match here
# |  ret <16 x i8> %result
# |  ^
# | /home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:20:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
# |               ^
# | <stdin>:11:50: note: scanning from here
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | <stdin>:11:50: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | /home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:31:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
# |               ^
# | <stdin>:16:54: note: scanning from here
# | define <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# |                                                      ^
# | <stdin>:16:54: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# |                                                      ^
# | /home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:53:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT1:%.*]] = insertelement <16 x i8> [[V]], i8 0, i64 15
# |               ^
# | <stdin>:26:58: note: scanning from here
# | define <16 x i8> @swizzle_out_of_bounds_1(<16 x i8> %v) {
# |                                                          ^
# | <stdin>:26:58: note: with "V" equal to "%v"
...

@llvm-ci
Copy link

llvm-ci commented Jan 8, 2026

LLVM Buildbot has detected a new failure on builder openmp-offload-amdgpu-runtime-2 running on rocm-worker-hw-02 while building llvm at step 8 "Add check check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/10/builds/20134

Here is the relevant piece of the build log for the reference
Step 8 (Add check check-llvm) failure: test (failure)
******************** TEST 'LLVM :: Transforms/InstCombine/WebAssembly/fold-swizzle.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/bin/opt < /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll -passes=instcombine -mtriple=wasm32-unknown-unknown -S | /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/bin/FileCheck /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# executed command: /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/bin/opt -passes=instcombine -mtriple=wasm32-unknown-unknown -S
# .---command stderr------------
# | /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/bin/opt: WARNING: failed to create target machine for 'wasm32-unknown-unknown': unable to get target for 'wasm32-unknown-unknown', see --version and --triple.
# `-----------------------------
# executed command: /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/bin/FileCheck /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# .---command stderr------------
# | /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:10:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: ret <16 x i8> [[V]]
# |               ^
# | <stdin>:6:51: note: scanning from here
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:6:51: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:8:2: note: possible intended match here
# |  ret <16 x i8> %result
# |  ^
# | /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:20:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
# |               ^
# | <stdin>:11:50: note: scanning from here
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | <stdin>:11:50: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:31:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
# |               ^
# | <stdin>:16:54: note: scanning from here
# | define <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# |                                                      ^
# | <stdin>:16:54: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# |                                                      ^
# | /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:53:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT1:%.*]] = insertelement <16 x i8> [[V]], i8 0, i64 15
# |               ^
# | <stdin>:26:58: note: scanning from here
# | define <16 x i8> @swizzle_out_of_bounds_1(<16 x i8> %v) {
# |                                                          ^
# | <stdin>:26:58: note: with "V" equal to "%v"
...

@llvm-ci
Copy link

llvm-ci commented Jan 8, 2026

LLVM Buildbot has detected a new failure on builder clang-m68k-linux-cross running on suse-gary-m68k-cross while building llvm at step 5 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/21185

Here is the relevant piece of the build log for the reference
Step 5 (ninja check 1) failure: stage 1 checked (failure)
******************** TEST 'LLVM :: Transforms/InstCombine/WebAssembly/fold-swizzle.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/opt < /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll -passes=instcombine -mtriple=wasm32-unknown-unknown -S | /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/FileCheck /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# executed command: /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/opt -passes=instcombine -mtriple=wasm32-unknown-unknown -S
# .---command stderr------------
# | /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/opt: WARNING: failed to create target machine for 'wasm32-unknown-unknown': unable to get target for 'wasm32-unknown-unknown', see --version and --triple.
# `-----------------------------
# executed command: /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/FileCheck /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# .---command stderr------------
# | /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:10:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: ret <16 x i8> [[V]]
# |               ^
# | <stdin>:6:51: note: scanning from here
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:6:51: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:8:2: note: possible intended match here
# |  ret <16 x i8> %result
# |  ^
# | /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:20:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
# |               ^
# | <stdin>:11:50: note: scanning from here
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | <stdin>:11:50: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:31:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
# |               ^
# | <stdin>:16:54: note: scanning from here
# | define <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# |                                                      ^
# | <stdin>:16:54: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# |                                                      ^
# | /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:53:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT1:%.*]] = insertelement <16 x i8> [[V]], i8 0, i64 15
# |               ^
# | <stdin>:26:58: note: scanning from here
# | define <16 x i8> @swizzle_out_of_bounds_1(<16 x i8> %v) {
# |                                                          ^
# | <stdin>:26:58: note: with "V" equal to "%v"
...

@llvm-ci
Copy link

llvm-ci commented Jan 8, 2026

LLVM Buildbot has detected a new failure on builder clang-armv8-quick running on linaro-clang-armv8-quick while building llvm at step 5 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/154/builds/26119

Here is the relevant piece of the build log for the reference
Step 5 (ninja check 1) failure: stage 1 checked (failure)
******************** TEST 'LLVM :: Transforms/InstCombine/WebAssembly/fold-swizzle.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/opt < /home/tcwg-buildbot/worker/clang-armv8-quick/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll -passes=instcombine -mtriple=wasm32-unknown-unknown -S | /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/FileCheck /home/tcwg-buildbot/worker/clang-armv8-quick/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# executed command: /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/opt -passes=instcombine -mtriple=wasm32-unknown-unknown -S
# .---command stderr------------
# | /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/opt: WARNING: failed to create target machine for 'wasm32-unknown-unknown': unable to get target for 'wasm32-unknown-unknown', see --version and --triple.
# `-----------------------------
# executed command: /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/FileCheck /home/tcwg-buildbot/worker/clang-armv8-quick/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# .---command stderr------------
# | /home/tcwg-buildbot/worker/clang-armv8-quick/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:10:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: ret <16 x i8> [[V]]
# |               ^
# | <stdin>:6:51: note: scanning from here
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:6:51: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:8:2: note: possible intended match here
# |  ret <16 x i8> %result
# |  ^
# | /home/tcwg-buildbot/worker/clang-armv8-quick/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:20:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
# |               ^
# | <stdin>:11:50: note: scanning from here
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | <stdin>:11:50: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | /home/tcwg-buildbot/worker/clang-armv8-quick/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:31:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
# |               ^
# | <stdin>:16:54: note: scanning from here
# | define <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# |                                                      ^
# | <stdin>:16:54: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# |                                                      ^
# | /home/tcwg-buildbot/worker/clang-armv8-quick/llvm/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:53:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT1:%.*]] = insertelement <16 x i8> [[V]], i8 0, i64 15
# |               ^
# | <stdin>:26:58: note: scanning from here
# | define <16 x i8> @swizzle_out_of_bounds_1(<16 x i8> %v) {
# |                                                          ^
# | <stdin>:26:58: note: with "V" equal to "%v"
...

@llvm-ci
Copy link

llvm-ci commented Jan 8, 2026

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-sie-win running on sie-win-worker while building llvm at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/46/builds/28742

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: Transforms/InstCombine/WebAssembly/fold-swizzle.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
z:\b\llvm-clang-x86_64-sie-win\build\bin\opt.exe < Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\test\Transforms\InstCombine\WebAssembly\fold-swizzle.ll -passes=instcombine -mtriple=wasm32-unknown-unknown -S | z:\b\llvm-clang-x86_64-sie-win\build\bin\filecheck.exe Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\test\Transforms\InstCombine\WebAssembly\fold-swizzle.ll
# executed command: 'z:\b\llvm-clang-x86_64-sie-win\build\bin\opt.exe' -passes=instcombine -mtriple=wasm32-unknown-unknown -S
# .---command stderr------------
# | z:\b\llvm-clang-x86_64-sie-win\build\bin\opt.exe: WARNING: failed to create target machine for 'wasm32-unknown-unknown': unable to get target for 'wasm32-unknown-unknown', see --version and --triple.
# `-----------------------------
# executed command: 'z:\b\llvm-clang-x86_64-sie-win\build\bin\filecheck.exe' 'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\test\Transforms\InstCombine\WebAssembly\fold-swizzle.ll'
# .---command stderr------------
# | �[1mZ:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\test\Transforms\InstCombine\WebAssembly\fold-swizzle.ll:10:15: �[0m�[0;1;31merror: �[0m�[1mCHECK-NEXT: expected string not found in input
�[0m# | �[1m�[0m; CHECK-NEXT: ret <16 x i8> [[V]]
# | �[0;1;32m              ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:6:51: �[0m�[0;1;30mnote: �[0m�[1mscanning from here
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_identity(<16 x i8> %v) {
# | �[0;1;32m                                                  ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:6:51: �[0m�[0;1;30mnote: �[0m�[1mwith "V" equal to "%v"
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_identity(<16 x i8> %v) {
# | �[0;1;32m                                                  ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:8:2: �[0m�[0;1;30mnote: �[0m�[1mpossible intended match here
�[0m# | �[1m�[0m ret <16 x i8> %result
# | �[0;1;32m ^
�[0m# | �[0;1;32m�[0m�[1mZ:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\test\Transforms\InstCombine\WebAssembly\fold-swizzle.ll:20:15: �[0m�[0;1;31merror: �[0m�[1mCHECK-NEXT: expected string not found in input
�[0m# | �[1m�[0m; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
# | �[0;1;32m              ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:11:50: �[0m�[0;1;30mnote: �[0m�[1mscanning from here
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# | �[0;1;32m                                                 ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:11:50: �[0m�[0;1;30mnote: �[0m�[1mwith "V" equal to "%v"
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# | �[0;1;32m                                                 ^
�[0m# | �[0;1;32m�[0m�[1mZ:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\test\Transforms\InstCombine\WebAssembly\fold-swizzle.ll:31:15: �[0m�[0;1;31merror: �[0m�[1mCHECK-NEXT: expected string not found in input
�[0m# | �[1m�[0m; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
# | �[0;1;32m              ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:16:54: �[0m�[0;1;30mnote: �[0m�[1mscanning from here
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# | �[0;1;32m                                                     ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:16:54: �[0m�[0;1;30mnote: �[0m�[1mwith "V" equal to "%v"
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# | �[0;1;32m                                                     ^
�[0m# | �[0;1;32m�[0m�[1mZ:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\test\Transforms\InstCombine\WebAssembly\fold-swizzle.ll:53:15: �[0m�[0;1;31merror: �[0m�[1mCHECK-NEXT: expected string not found in input
�[0m# | �[1m�[0m; CHECK-NEXT: [[RESULT1:%.*]] = insertelement <16 x i8> [[V]], i8 0, i64 15
# | �[0;1;32m              ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:26:58: �[0m�[0;1;30mnote: �[0m�[1mscanning from here
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_out_of_bounds_1(<16 x i8> %v) {
# | �[0;1;32m                                                         ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:26:58: �[0m�[0;1;30mnote: �[0m�[1mwith "V" equal to "%v"
...

@llvm-ci
Copy link

llvm-ci commented Jan 8, 2026

LLVM Buildbot has detected a new failure on builder llvm-clang-aarch64-darwin running on doug-worker-5 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/33825

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: Transforms/InstCombine/WebAssembly/fold-swizzle.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/opt < /Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll -passes=instcombine -mtriple=wasm32-unknown-unknown -S | /Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# executed command: /Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/opt -passes=instcombine -mtriple=wasm32-unknown-unknown -S
# .---command stderr------------
# | /Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/opt: WARNING: failed to create target machine for 'wasm32-unknown-unknown': unable to get target for 'wasm32-unknown-unknown', see --version and --triple.
# `-----------------------------
# executed command: /Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# .---command stderr------------
# | �[1m/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:10:15: �[0m�[0;1;31merror: �[0m�[1mCHECK-NEXT: expected string not found in input
�[0m# | �[1m�[0m; CHECK-NEXT: ret <16 x i8> [[V]]
# | �[0;1;32m              ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:6:51: �[0m�[0;1;30mnote: �[0m�[1mscanning from here
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_identity(<16 x i8> %v) {
# | �[0;1;32m                                                  ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:6:51: �[0m�[0;1;30mnote: �[0m�[1mwith "V" equal to "%v"
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_identity(<16 x i8> %v) {
# | �[0;1;32m                                                  ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:8:2: �[0m�[0;1;30mnote: �[0m�[1mpossible intended match here
�[0m# | �[1m�[0m ret <16 x i8> %result
# | �[0;1;32m ^
�[0m# | �[0;1;32m�[0m�[1m/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:20:15: �[0m�[0;1;31merror: �[0m�[1mCHECK-NEXT: expected string not found in input
�[0m# | �[1m�[0m; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
# | �[0;1;32m              ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:11:50: �[0m�[0;1;30mnote: �[0m�[1mscanning from here
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# | �[0;1;32m                                                 ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:11:50: �[0m�[0;1;30mnote: �[0m�[1mwith "V" equal to "%v"
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# | �[0;1;32m                                                 ^
�[0m# | �[0;1;32m�[0m�[1m/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:31:15: �[0m�[0;1;31merror: �[0m�[1mCHECK-NEXT: expected string not found in input
�[0m# | �[1m�[0m; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
# | �[0;1;32m              ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:16:54: �[0m�[0;1;30mnote: �[0m�[1mscanning from here
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# | �[0;1;32m                                                     ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:16:54: �[0m�[0;1;30mnote: �[0m�[1mwith "V" equal to "%v"
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# | �[0;1;32m                                                     ^
�[0m# | �[0;1;32m�[0m�[1m/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:53:15: �[0m�[0;1;31merror: �[0m�[1mCHECK-NEXT: expected string not found in input
�[0m# | �[1m�[0m; CHECK-NEXT: [[RESULT1:%.*]] = insertelement <16 x i8> [[V]], i8 0, i64 15
# | �[0;1;32m              ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:26:58: �[0m�[0;1;30mnote: �[0m�[1mscanning from here
�[0m# | �[1m�[0mdefine <16 x i8> @swizzle_out_of_bounds_1(<16 x i8> %v) {
# | �[0;1;32m                                                         ^
�[0m# | �[0;1;32m�[0m�[1m<stdin>:26:58: �[0m�[0;1;30mnote: �[0m�[1mwith "V" equal to "%v"
...

@llvm-ci
Copy link

llvm-ci commented Jan 8, 2026

LLVM Buildbot has detected a new failure on builder fuchsia-x86_64-linux running on fuchsia-debian-64-us-central1-a-1 while building llvm at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/11/builds/31086

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/fuchsia-linux.py ...' (failure)
...
  Passed           : 48295 (97.23%)
  Expectedly Failed:    24 (0.05%)
[1480/1482] Linking CXX executable unittests/Frontend/LLVMFrontendTests
[1481/1482] Running the LLVM regression tests
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:561: note: using ld.lld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n4wx1uym/bin/ld.lld
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:561: note: using lld-link: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n4wx1uym/bin/lld-link
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:561: note: using ld64.lld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n4wx1uym/bin/ld64.lld
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:561: note: using wasm-ld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n4wx1uym/bin/wasm-ld
-- Testing: 62913 tests, 60 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70
FAIL: LLVM :: Transforms/InstCombine/WebAssembly/fold-swizzle.ll (47021 of 62913)
******************** TEST 'LLVM :: Transforms/InstCombine/WebAssembly/fold-swizzle.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n4wx1uym/bin/opt < /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll -passes=instcombine -mtriple=wasm32-unknown-unknown -S | /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n4wx1uym/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# executed command: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n4wx1uym/bin/opt -passes=instcombine -mtriple=wasm32-unknown-unknown -S
# .---command stderr------------
# | /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n4wx1uym/bin/opt: WARNING: failed to create target machine for 'wasm32-unknown-unknown': unable to get target for 'wasm32-unknown-unknown', see --version and --triple.
# `-----------------------------
# executed command: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n4wx1uym/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# .---command stderr------------
# | /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:10:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: ret <16 x i8> [[V]]
# |               ^
# | <stdin>:6:51: note: scanning from here
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:6:51: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:8:2: note: possible intended match here
# |  ret <16 x i8> %result
# |  ^
# | /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:20:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
# |               ^
# | <stdin>:11:50: note: scanning from here
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | <stdin>:11:50: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:31:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
# |               ^
# | <stdin>:16:54: note: scanning from here
Step 7 (check) failure: check (failure)
...
  Passed           : 48295 (97.23%)
  Expectedly Failed:    24 (0.05%)
[1480/1482] Linking CXX executable unittests/Frontend/LLVMFrontendTests
[1481/1482] Running the LLVM regression tests
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:561: note: using ld.lld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n4wx1uym/bin/ld.lld
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:561: note: using lld-link: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n4wx1uym/bin/lld-link
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:561: note: using ld64.lld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n4wx1uym/bin/ld64.lld
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:561: note: using wasm-ld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n4wx1uym/bin/wasm-ld
-- Testing: 62913 tests, 60 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70
FAIL: LLVM :: Transforms/InstCombine/WebAssembly/fold-swizzle.ll (47021 of 62913)
******************** TEST 'LLVM :: Transforms/InstCombine/WebAssembly/fold-swizzle.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n4wx1uym/bin/opt < /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll -passes=instcombine -mtriple=wasm32-unknown-unknown -S | /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n4wx1uym/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# executed command: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n4wx1uym/bin/opt -passes=instcombine -mtriple=wasm32-unknown-unknown -S
# .---command stderr------------
# | /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n4wx1uym/bin/opt: WARNING: failed to create target machine for 'wasm32-unknown-unknown': unable to get target for 'wasm32-unknown-unknown', see --version and --triple.
# `-----------------------------
# executed command: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n4wx1uym/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# .---command stderr------------
# | /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:10:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: ret <16 x i8> [[V]]
# |               ^
# | <stdin>:6:51: note: scanning from here
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:6:51: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:8:2: note: possible intended match here
# |  ret <16 x i8> %result
# |  ^
# | /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:20:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
# |               ^
# | <stdin>:11:50: note: scanning from here
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | <stdin>:11:50: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:31:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
# |               ^
# | <stdin>:16:54: note: scanning from here

@llvm-ci
Copy link

llvm-ci commented Jan 8, 2026

LLVM Buildbot has detected a new failure on builder openmp-offload-sles-build-only running on rocm-worker-hw-04-sles while building llvm at step 9 "Add check check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/140/builds/36664

Here is the relevant piece of the build log for the reference
Step 9 (Add check check-llvm) failure: test (failure)
******************** TEST 'LLVM :: Transforms/InstCombine/WebAssembly/fold-swizzle.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/opt < /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll -passes=instcombine -mtriple=wasm32-unknown-unknown -S | /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# executed command: /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/opt -passes=instcombine -mtriple=wasm32-unknown-unknown -S
# .---command stderr------------
# | /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/opt: WARNING: failed to create target machine for 'wasm32-unknown-unknown': unable to get target for 'wasm32-unknown-unknown', see --version and --triple.
# `-----------------------------
# executed command: /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# .---command stderr------------
# | /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:10:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: ret <16 x i8> [[V]]
# |               ^
# | <stdin>:6:51: note: scanning from here
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:6:51: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:8:2: note: possible intended match here
# |  ret <16 x i8> %result
# |  ^
# | /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:20:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
# |               ^
# | <stdin>:11:50: note: scanning from here
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | <stdin>:11:50: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:31:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
# |               ^
# | <stdin>:16:54: note: scanning from here
# | define <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# |                                                      ^
# | <stdin>:16:54: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# |                                                      ^
# | /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:53:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT1:%.*]] = insertelement <16 x i8> [[V]], i8 0, i64 15
# |               ^
# | <stdin>:26:58: note: scanning from here
# | define <16 x i8> @swizzle_out_of_bounds_1(<16 x i8> %v) {
# |                                                          ^
# | <stdin>:26:58: note: with "V" equal to "%v"
...

@llvm-ci
Copy link

llvm-ci commented Jan 8, 2026

LLVM Buildbot has detected a new failure on builder llvm-nvptx64-nvidia-win running on as-builder-8 while building llvm at step 7 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/155/builds/16341

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM :: Transforms/InstCombine/WebAssembly/fold-swizzle.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\opt.exe < C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\llvm-project\llvm\test\Transforms\InstCombine\WebAssembly\fold-swizzle.ll -passes=instcombine -mtriple=wasm32-unknown-unknown -S | c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\filecheck.exe C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\llvm-project\llvm\test\Transforms\InstCombine\WebAssembly\fold-swizzle.ll
# executed command: 'c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\opt.exe' -passes=instcombine -mtriple=wasm32-unknown-unknown -S
# .---command stderr------------
# | c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\opt.exe: WARNING: failed to create target machine for 'wasm32-unknown-unknown': unable to get target for 'wasm32-unknown-unknown', see --version and --triple.
# `-----------------------------
# executed command: 'c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\filecheck.exe' 'C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\llvm-project\llvm\test\Transforms\InstCombine\WebAssembly\fold-swizzle.ll'
# .---command stderr------------
# | C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\llvm-project\llvm\test\Transforms\InstCombine\WebAssembly\fold-swizzle.ll:10:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: ret <16 x i8> [[V]]
# |               ^
# | <stdin>:6:51: note: scanning from here
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:6:51: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:8:2: note: possible intended match here
# |  ret <16 x i8> %result
# |  ^
# | C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\llvm-project\llvm\test\Transforms\InstCombine\WebAssembly\fold-swizzle.ll:20:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
# |               ^
# | <stdin>:11:50: note: scanning from here
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | <stdin>:11:50: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\llvm-project\llvm\test\Transforms\InstCombine\WebAssembly\fold-swizzle.ll:31:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
# |               ^
# | <stdin>:16:54: note: scanning from here
# | define <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# |                                                      ^
# | <stdin>:16:54: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# |                                                      ^
# | C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\llvm-project\llvm\test\Transforms\InstCombine\WebAssembly\fold-swizzle.ll:53:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT1:%.*]] = insertelement <16 x i8> [[V]], i8 0, i64 15
# |               ^
# | <stdin>:26:58: note: scanning from here
# | define <16 x i8> @swizzle_out_of_bounds_1(<16 x i8> %v) {
# |                                                          ^
# | <stdin>:26:58: note: with "V" equal to "%v"
...

@llvm-ci
Copy link

llvm-ci commented Jan 8, 2026

LLVM Buildbot has detected a new failure on builder llvm-clang-ubuntu-x-aarch64-pauth running on as-builder-11 while building llvm at step 14 "test-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/224/builds/1473

Here is the relevant piece of the build log for the reference
Step 14 (test-check-llvm) failure: Test just built components: check-llvm completed (failure)
******************** TEST 'LLVM :: Transforms/InstCombine/WebAssembly/fold-swizzle.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/home/buildbot/worker/as-builder-11/x-aarch64-pauth/build/bin/opt < /home/buildbot/worker/as-builder-11/x-aarch64-pauth/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll -passes=instcombine -mtriple=wasm32-unknown-unknown -S | /home/buildbot/worker/as-builder-11/x-aarch64-pauth/build/bin/FileCheck /home/buildbot/worker/as-builder-11/x-aarch64-pauth/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# executed command: /home/buildbot/worker/as-builder-11/x-aarch64-pauth/build/bin/opt -passes=instcombine -mtriple=wasm32-unknown-unknown -S
# .---command stderr------------
# | /home/buildbot/worker/as-builder-11/x-aarch64-pauth/build/bin/opt: WARNING: failed to create target machine for 'wasm32-unknown-unknown': unable to get target for 'wasm32-unknown-unknown', see --version and --triple.
# `-----------------------------
# executed command: /home/buildbot/worker/as-builder-11/x-aarch64-pauth/build/bin/FileCheck /home/buildbot/worker/as-builder-11/x-aarch64-pauth/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# .---command stderr------------
# | /home/buildbot/worker/as-builder-11/x-aarch64-pauth/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:10:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: ret <16 x i8> [[V]]
# |               ^
# | <stdin>:6:51: note: scanning from here
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:6:51: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:8:2: note: possible intended match here
# |  ret <16 x i8> %result
# |  ^
# | /home/buildbot/worker/as-builder-11/x-aarch64-pauth/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:20:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
# |               ^
# | <stdin>:11:50: note: scanning from here
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | <stdin>:11:50: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | /home/buildbot/worker/as-builder-11/x-aarch64-pauth/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:31:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
# |               ^
# | <stdin>:16:54: note: scanning from here
# | define <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# |                                                      ^
# | <stdin>:16:54: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# |                                                      ^
# | /home/buildbot/worker/as-builder-11/x-aarch64-pauth/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:53:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT1:%.*]] = insertelement <16 x i8> [[V]], i8 0, i64 15
# |               ^
# | <stdin>:26:58: note: scanning from here
# | define <16 x i8> @swizzle_out_of_bounds_1(<16 x i8> %v) {
# |                                                          ^
# | <stdin>:26:58: note: with "V" equal to "%v"
...

@valadaptive
Copy link
Contributor Author

I have no idea what's going on with the buildbot failures. I ran the regression test suite locally, on main with this PR merged, and everything passes. The buildbot logs also have this type of warning:

/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/opt: WARNING: failed to create target machine for 'wasm32-unknown-unknown': unable to get target for 'wasm32-unknown-unknown', see --version and --triple.

Do we just not build all backends for some buildbot targets? Is there a hardcoded list of InstCombine tests to skip based on folder names that I should've updated or something?

lukel97 pushed a commit that referenced this pull request Jan 8, 2026
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Jan 8, 2026
@llvm-ci
Copy link

llvm-ci commented Jan 8, 2026

LLVM Buildbot has detected a new failure on builder llvm-nvptx64-nvidia-ubuntu running on as-builder-7 while building llvm at step 6 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/160/builds/30421

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM :: Transforms/InstCombine/WebAssembly/fold-swizzle.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/bin/opt < /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll -passes=instcombine -mtriple=wasm32-unknown-unknown -S | /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# executed command: /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/bin/opt -passes=instcombine -mtriple=wasm32-unknown-unknown -S
# .---command stderr------------
# | /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/bin/opt: WARNING: failed to create target machine for 'wasm32-unknown-unknown': unable to get target for 'wasm32-unknown-unknown', see --version and --triple.
# `-----------------------------
# executed command: /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# .---command stderr------------
# | /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:10:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: ret <16 x i8> [[V]]
# |               ^
# | <stdin>:6:51: note: scanning from here
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:6:51: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:8:2: note: possible intended match here
# |  ret <16 x i8> %result
# |  ^
# | /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:20:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
# |               ^
# | <stdin>:11:50: note: scanning from here
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | <stdin>:11:50: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:31:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
# |               ^
# | <stdin>:16:54: note: scanning from here
# | define <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# |                                                      ^
# | <stdin>:16:54: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# |                                                      ^
# | /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:53:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT1:%.*]] = insertelement <16 x i8> [[V]], i8 0, i64 15
# |               ^
# | <stdin>:26:58: note: scanning from here
# | define <16 x i8> @swizzle_out_of_bounds_1(<16 x i8> %v) {
# |                                                          ^
# | <stdin>:26:58: note: with "V" equal to "%v"
...

@llvm-ci
Copy link

llvm-ci commented Jan 8, 2026

LLVM Buildbot has detected a new failure on builder llvm-nvptx-nvidia-ubuntu running on as-builder-7 while building llvm at step 6 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/180/builds/30561

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM :: Transforms/InstCombine/WebAssembly/fold-swizzle.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/bin/opt < /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll -passes=instcombine -mtriple=wasm32-unknown-unknown -S | /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# executed command: /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/bin/opt -passes=instcombine -mtriple=wasm32-unknown-unknown -S
# .---command stderr------------
# | /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/bin/opt: WARNING: failed to create target machine for 'wasm32-unknown-unknown': unable to get target for 'wasm32-unknown-unknown', see --version and --triple.
# `-----------------------------
# executed command: /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll
# .---command stderr------------
# | /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:10:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: ret <16 x i8> [[V]]
# |               ^
# | <stdin>:6:51: note: scanning from here
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:6:51: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_identity(<16 x i8> %v) {
# |                                                   ^
# | <stdin>:8:2: note: possible intended match here
# |  ret <16 x i8> %result
# |  ^
# | /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:20:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
# |               ^
# | <stdin>:11:50: note: scanning from here
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | <stdin>:11:50: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_reverse(<16 x i8> %v) {
# |                                                  ^
# | /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:31:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT:%.*]] = shufflevector <16 x i8> [[V]], <16 x i8> poison, <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
# |               ^
# | <stdin>:16:54: note: scanning from here
# | define <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# |                                                      ^
# | <stdin>:16:54: note: with "V" equal to "%v"
# | define <16 x i8> @swizzle_with_poison(<16 x i8> %v) {
# |                                                      ^
# | /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/Transforms/InstCombine/WebAssembly/fold-swizzle.ll:53:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[RESULT1:%.*]] = insertelement <16 x i8> [[V]], i8 0, i64 15
# |               ^
# | <stdin>:26:58: note: scanning from here
# | define <16 x i8> @swizzle_out_of_bounds_1(<16 x i8> %v) {
# |                                                          ^
# | <stdin>:26:58: note: with "V" equal to "%v"
...

@dschuff
Copy link
Member

dschuff commented Jan 8, 2026

I have no idea what's going on with the buildbot failures. I ran the regression test suite locally, on main with this PR merged, and everything passes. The buildbot logs also have this type of warning:

/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/opt: WARNING: failed to create target machine for 'wasm32-unknown-unknown': unable to get target for 'wasm32-unknown-unknown', see --version and --triple.

Do we just not build all backends for some buildbot targets? Is there a hardcoded list of InstCombine tests to skip based on folder names that I should've updated or something?

Ah yes, sorry I missed this last night. Most users (and many bots) just enable a subset of the targets. Looks like you figured out how to fix it. Another mechanism is a REQUIRES line in the test that will cause it to be skipped when the target is not enabled (e.g. REQUIRES: webassembly-registered-target). That works on the file level rather than the directory level, which is sometimes more desirable.

navaneethshan pushed a commit to qualcomm/cpullvm-toolchain that referenced this pull request Jan 8, 2026
kshitijvp pushed a commit to kshitijvp/llvm-project that referenced this pull request Jan 9, 2026
…e` to `shufflevector` (llvm#169110)

Resolves llvm#169058.

This adds ~~an InstCombine pass~~ a TTI hook to the WebAssembly backend
that folds `i8x16.swizzle` and `i8x16.relaxed.swizzle` operations to
`shufflevector` operations if their mask operands are constant.

This is mainly useful for abstractions over the raw intrinsics--for
instance, in architecture-generic SIMD code that may not be able to
expose the constant shuffles due to type system limitations.

I took most of this from the x86 backend (in particular,
`simplifyX86vpermilvar` in `X86InstCombineIntrinsic`), and adapted it
for the WebAssembly backend. There wasn't any previous
`instCombineIntrinsic` method on the WebAssembly `TargetTransformInfo`,
so I added it. Right now, this swizzle optimization is the only one it
performs.

As I noted in the transform itself, the "relaxed" swizzle actually has
stricter preconditions than the non-relaxed one. If a non-negative but
still out-of-bounds index is provided, the "relaxed" swizzle can choose
between returning 0 and the lane at the index modulo 16. However, it
must make the same choice every time, and we don't know which choice the
runtime will make, so we can't constant-fold it.

The regression tests were mostly generated by Claude and adapted a bit
by me (I tried to follow the [InstCombine contributor
guide](https://llvm.org/docs/InstCombineContributorGuide.html#tests)).
There was previously no WebAssembly subdirectory within the InstCombine
tests, so I created that too; as of now, the swizzle fold test is the
only file in it. Everything else was written by myself (well, partly
copy-pasted from the x86 backend).

I'm not sure how to write an Alive2 test for this; I can't find any
examples where the input is an arbitrary constant.
kshitijvp pushed a commit to kshitijvp/llvm-project that referenced this pull request Jan 9, 2026
navaneethshan pushed a commit to qualcomm/cpullvm-toolchain that referenced this pull request Jan 9, 2026
Priyanshu3820 pushed a commit to Priyanshu3820/llvm-project that referenced this pull request Jan 18, 2026
…e` to `shufflevector` (llvm#169110)

Resolves llvm#169058.

This adds ~~an InstCombine pass~~ a TTI hook to the WebAssembly backend
that folds `i8x16.swizzle` and `i8x16.relaxed.swizzle` operations to
`shufflevector` operations if their mask operands are constant.

This is mainly useful for abstractions over the raw intrinsics--for
instance, in architecture-generic SIMD code that may not be able to
expose the constant shuffles due to type system limitations.

I took most of this from the x86 backend (in particular,
`simplifyX86vpermilvar` in `X86InstCombineIntrinsic`), and adapted it
for the WebAssembly backend. There wasn't any previous
`instCombineIntrinsic` method on the WebAssembly `TargetTransformInfo`,
so I added it. Right now, this swizzle optimization is the only one it
performs.

As I noted in the transform itself, the "relaxed" swizzle actually has
stricter preconditions than the non-relaxed one. If a non-negative but
still out-of-bounds index is provided, the "relaxed" swizzle can choose
between returning 0 and the lane at the index modulo 16. However, it
must make the same choice every time, and we don't know which choice the
runtime will make, so we can't constant-fold it.

The regression tests were mostly generated by Claude and adapted a bit
by me (I tried to follow the [InstCombine contributor
guide](https://llvm.org/docs/InstCombineContributorGuide.html#tests)).
There was previously no WebAssembly subdirectory within the InstCombine
tests, so I created that too; as of now, the swizzle fold test is the
only file in it. Everything else was written by myself (well, partly
copy-pasted from the x86 backend).

I'm not sure how to write an Alive2 test for this; I can't find any
examples where the input is an arbitrary constant.
Priyanshu3820 pushed a commit to Priyanshu3820/llvm-project that referenced this pull request Jan 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:WebAssembly llvm:instcombine Covers the InstCombine, InstSimplify and AggressiveInstCombine passes llvm:transforms

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wasm: i8x16.swizzle with a constant value should be optimized to i8x16.shuffle

7 participants