Skip to content

Conversation

dschuff
Copy link
Member

@dschuff dschuff commented Oct 6, 2025

This code is activated on all INTRINSIC_WO_CHAIN but only handles
a selection. However it was trying to read the arguments before
checking which intrinsic it was handling. This fails for intrinsics
that have no arguments.

This code is activated on all INTRINSIC_WO_CHAIN but only handles
a selection. However it was trying to read the arguments before
checking which intrinsic it was handling. This fails for intrinsics
that have no arguments.
@llvmbot
Copy link
Member

llvmbot commented Oct 6, 2025

@llvm/pr-subscribers-backend-webassembly

Author: Derek Schuff (dschuff)

Changes

This code is activated on all INTRINSIC_WO_CHAIN but only handles
a selection. However it was trying to read the arguments before
checking which intrinsic it was handling. This fails for intrinsics
that have no arguments.


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

2 Files Affected:

  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp (+2-1)
  • (modified) llvm/test/CodeGen/WebAssembly/simd-setcc-reductions.ll (+8)
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
index 163bf9ba5b089..64723340051b8 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -3209,7 +3209,8 @@ static SDValue performAnyAllCombine(SDNode *N, SelectionDAG &DAG) {
   using namespace llvm::SDPatternMatch;
 
   SDValue LHS;
-  if (!sd_match(N->getOperand(1),
+  if (N->getNumOperands() < 2 ||
+      !sd_match(N->getOperand(1),
                 m_c_SetCC(m_Value(LHS), m_Zero(), m_CondCode())))
     return SDValue();
   EVT LT = LHS.getValueType();
diff --git a/llvm/test/CodeGen/WebAssembly/simd-setcc-reductions.ll b/llvm/test/CodeGen/WebAssembly/simd-setcc-reductions.ll
index 172ff53bfb458..e4156e4776132 100644
--- a/llvm/test/CodeGen/WebAssembly/simd-setcc-reductions.ll
+++ b/llvm/test/CodeGen/WebAssembly/simd-setcc-reductions.ll
@@ -132,4 +132,12 @@ define i32 @all_true_2_4_i32(<4 x i32> %v) {
   ret i32 %conv3
 }
 
+; Regression test for the intrinsic pattern matcher with nullary intrinsics
+define i64 @other_intrinsic() #0 {
+entry:
+  %0 = call i64 @llvm.wasm.tls.align.i64()
+  ret i64 %0
+}
+
+attributes #0 = { "target-features"="+atomics" }
 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants