Skip to content

Commit 076ceb7

Browse files
topperctru
authored andcommitted
[DAGCombiner] Replace LegalOperations check in visitSIGN_EXTEND with LegalTypes.
This is guarding a check for isTypeLegal so it should check is LegalTypes. Fixes PR61111. Reviewed By: RKSimon Differential Revision: https://reviews.llvm.org/D145139 (cherry picked from commit c546f13)
1 parent 29a7dbb commit 076ceb7

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12454,7 +12454,8 @@ SDValue DAGCombiner::visitSIGN_EXTEND(SDNode *N) {
1245412454
if (N0.getOpcode() == ISD::SIGN_EXTEND_INREG) {
1245512455
SDValue N00 = N0.getOperand(0);
1245612456
EVT ExtVT = cast<VTSDNode>(N0->getOperand(1))->getVT();
12457-
if (N00.getOpcode() == ISD::TRUNCATE && (!LegalOperations || TLI.isTypeLegal(ExtVT))) {
12457+
if (N00.getOpcode() == ISD::TRUNCATE &&
12458+
(!LegalTypes || TLI.isTypeLegal(ExtVT))) {
1245812459
SDValue T = DAG.getNode(ISD::TRUNCATE, DL, ExtVT, N00.getOperand(0));
1245912460
return DAG.getNode(ISD::SIGN_EXTEND, DL, VT, T);
1246012461
}

llvm/test/CodeGen/AArch64/pr61111.ll

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc < %s -mtriple=aarch64-linux-gnu | FileCheck %s
3+
4+
define i62 @f(i1 %0) {
5+
; CHECK-LABEL: f:
6+
; CHECK: // %bb.0:
7+
; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
8+
; CHECK-NEXT: and x8, x0, #0x1
9+
; CHECK-NEXT: sub x8, x8, #1
10+
; CHECK-NEXT: tst x8, #0x3fffffffffffffff
11+
; CHECK-NEXT: cset w0, ne
12+
; CHECK-NEXT: ret
13+
%2 = zext i1 %0 to i59
14+
%3 = call { i59, i1 } @llvm.umul.with.overflow.i59(i59 %2, i59 -1)
15+
%4 = extractvalue { i59, i1 } %3, 0
16+
%5 = trunc i59 %4 to i21
17+
%6 = trunc i59 %4 to i21
18+
%7 = ashr i21 %5, %6
19+
%8 = sext i21 %7 to i62
20+
%9 = icmp ugt i62 -1, %8
21+
%10 = zext i1 %9 to i62
22+
ret i62 %10
23+
}
24+
25+
declare { i59, i1 } @llvm.umul.with.overflow.i59(i59, i59)

0 commit comments

Comments
 (0)