Skip to content

Commit c9a86fa

Browse files
committed
[DAG] canCreateUndefOrPoison - fix missing argument typo
We were missing the PoisonOnly argument (so Depth + 1 was being used instead and the default Depth = 0 argument then being silently used) Fixes #94145 and serves as the test case for 9e22c7a
1 parent 8917afa commit c9a86fa

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5286,7 +5286,7 @@ bool SelectionDAG::canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
52865286
// If the max shift amount isn't in range, then the shift can
52875287
// create poison.
52885288
return !isGuaranteedNotToBeUndefOrPoison(Op.getOperand(1), DemandedElts,
5289-
Depth + 1) ||
5289+
PoisonOnly, Depth + 1) ||
52905290
!getValidMaximumShiftAmount(Op, DemandedElts, Depth + 1);
52915291

52925292
case ISD::SCALAR_TO_VECTOR:

llvm/test/CodeGen/RISCV/pr94145.ll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc < %s -mtriple=riscv32-- | FileCheck %s
3+
; RUN: llc < %s -mtriple=riscv64-- | FileCheck %s
4+
5+
define i32 @PR94145(i16 %a0) {
6+
; CHECK-LABEL: PR94145:
7+
; CHECK: # %bb.0:
8+
; CHECK-NEXT: andi a0, a0, 2
9+
; CHECK-NEXT: seqz a0, a0
10+
; CHECK-NEXT: li a1, 1
11+
; CHECK-NEXT: sll a0, a1, a0
12+
; CHECK-NEXT: ret
13+
%lshr = lshr i16 %a0, 1
14+
%and = and i16 %lshr, 1
15+
%xor = xor i16 %and, 1
16+
%shl = shl i16 1, %xor
17+
%freeze = freeze i16 %shl
18+
%zext = zext i16 %freeze to i32
19+
ret i32 %zext
20+
}

0 commit comments

Comments
 (0)