Skip to content

Commit 00eef4f

Browse files
committed
[SelectionDAG] Fix mismatched truncate when combine BUILD_VECTOR with EXTRACT_SUBVECTOR
Just use correct type for truncation. Fixes PR59625 Differential Revision: https://reviews.llvm.org/D145757
1 parent 57b78fa commit 00eef4f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23525,7 +23525,7 @@ SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode *N) {
2352523525
if (NumElems == 1) {
2352623526
SDValue Src = V->getOperand(IdxVal);
2352723527
if (EltVT != Src.getValueType())
23528-
Src = DAG.getNode(ISD::TRUNCATE, SDLoc(N), InVT, Src);
23528+
Src = DAG.getNode(ISD::TRUNCATE, SDLoc(N), EltVT, Src);
2352923529
return DAG.getBitcast(NVT, Src);
2353023530
}
2353123531

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2+
; RUN: llc < %s -mtriple=wasm32-- -mattr=+simd128 | FileCheck --check-prefix=CHECK %s
3+
; RUN: llc < %s -mtriple=wasm64-- -mattr=+simd128 | FileCheck --check-prefix=CHECK %s
4+
5+
define <1 x i16> @f(<1 x i16> %0) {
6+
; CHECK-LABEL: f:
7+
; CHECK: .functype f (v128) -> (v128)
8+
; CHECK-NEXT: # %bb.0: # %BB
9+
; CHECK-NEXT: v128.const 0, 0, 0, 0, 0, 0, 0, 0
10+
; CHECK-NEXT: # fallthrough-return
11+
BB:
12+
%B2 = srem <1 x i16> %0, %0
13+
br label %BB1
14+
15+
BB1: ; preds = %BB
16+
%B = urem <1 x i16> %B2, <i16 3>
17+
ret <1 x i16> %B
18+
}

0 commit comments

Comments
 (0)