Skip to content

Commit 3416a8b

Browse files
committed
[WebAssembly] Check intrinsic argument count before Any/All combine
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.
1 parent 9c0e09e commit 3416a8b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3209,7 +3209,8 @@ static SDValue performAnyAllCombine(SDNode *N, SelectionDAG &DAG) {
32093209
using namespace llvm::SDPatternMatch;
32103210

32113211
SDValue LHS;
3212-
if (!sd_match(N->getOperand(1),
3212+
if (N->getNumOperands() < 2 ||
3213+
!sd_match(N->getOperand(1),
32133214
m_c_SetCC(m_Value(LHS), m_Zero(), m_CondCode())))
32143215
return SDValue();
32153216
EVT LT = LHS.getValueType();

llvm/test/CodeGen/WebAssembly/simd-setcc-reductions.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,12 @@ define i32 @all_true_2_4_i32(<4 x i32> %v) {
132132
ret i32 %conv3
133133
}
134134

135+
; Regression test for the intrinsic pattern matcher with nullary intrinsics
136+
define i64 @other_intrinsic() #0 {
137+
entry:
138+
%0 = call i64 @llvm.wasm.tls.align.i64()
139+
ret i64 %0
140+
}
141+
142+
attributes #0 = { "target-features"="+atomics" }
135143

0 commit comments

Comments
 (0)