Skip to content

Commit abc8aac

Browse files
authored
[WebAssembly] Check intrinsic argument count before Any/All combine (#162163)
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 566040e commit abc8aac

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,17 @@ 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+
; CHECK-LABEL: other_intrinsic:
138+
; CHECK: .functype other_intrinsic () -> (i64)
139+
; CHECK-NEXT: # %bb.0: # %entry
140+
; CHECK-NEXT: global.get $push0=, __tls_align
141+
; CHECK-NEXT: return $pop0
142+
entry:
143+
%0 = call i64 @llvm.wasm.tls.align.i64()
144+
ret i64 %0
145+
}
146+
147+
attributes #0 = { "target-features"="+atomics" }
135148

0 commit comments

Comments
 (0)