Skip to content

Commit 8505c3b

Browse files
committed
[DAG] canCreateUndefOrPoison - remove AssertSext/AssertZext assumption that they never create undef/poison
We need to assume that we generate poison if the assertions failed Fixes #66603
1 parent 309e41d commit 8505c3b

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5011,8 +5011,6 @@ bool SelectionDAG::canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
50115011

50125012
unsigned Opcode = Op.getOpcode();
50135013
switch (Opcode) {
5014-
case ISD::AssertSext:
5015-
case ISD::AssertZext:
50165014
case ISD::FREEZE:
50175015
case ISD::CONCAT_VECTORS:
50185016
case ISD::INSERT_SUBVECTOR:

llvm/test/CodeGen/AArch64/pr66603.ll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
22
; RUN: llc < %s -mtriple=aarch64-- -verify-machineinstrs | FileCheck %s
33

4+
; Don't fold freeze(assertsext(x)) -> assertsext(freeze(x))
45
define i32 @PR66603(double %x) nounwind {
56
; CHECK-LABEL: PR66603:
67
; CHECK: // %bb.0:
7-
; CHECK-NEXT: fcvtzs w0, d0
8+
; CHECK-NEXT: fcvtzs w8, d0
9+
; CHECK-NEXT: sxtb w0, w8
810
; CHECK-NEXT: ret
911
%as_i8 = fptosi double %x to i8
1012
%frozen_i8 = freeze i8 %as_i8

llvm/test/CodeGen/RISCV/pr66603.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22
; RUN: llc < %s -mtriple=riscv32-- -mattr=+d -verify-machineinstrs | FileCheck %s -check-prefix=RV32
33
; RUN: llc < %s -mtriple=riscv64-- -mattr=+d -verify-machineinstrs | FileCheck %s -check-prefix=RV64
44

5+
; Don't fold freeze(assertsext(x)) -> assertsext(freeze(x))
56
define i32 @PR66603(double %x) nounwind {
67
; RV32-LABEL: PR66603:
78
; RV32: # %bb.0:
89
; RV32-NEXT: fcvt.w.d a0, fa0, rtz
10+
; RV32-NEXT: slli a0, a0, 24
11+
; RV32-NEXT: srai a0, a0, 24
912
; RV32-NEXT: ret
1013
;
1114
; RV64-LABEL: PR66603:
1215
; RV64: # %bb.0:
1316
; RV64-NEXT: fcvt.l.d a0, fa0, rtz
17+
; RV64-NEXT: slli a0, a0, 56
18+
; RV64-NEXT: srai a0, a0, 56
1419
; RV64-NEXT: ret
1520
%as_i8 = fptosi double %x to i8
1621
%frozen_i8 = freeze i8 %as_i8

llvm/test/CodeGen/RISCV/rv64zbb.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ define i32 @abs_i32(i32 %x) {
14221422
define signext i32 @abs_i32_sext(i32 signext %x) {
14231423
; RV64I-LABEL: abs_i32_sext:
14241424
; RV64I: # %bb.0:
1425-
; RV64I-NEXT: srai a1, a0, 31
1425+
; RV64I-NEXT: sraiw a1, a0, 31
14261426
; RV64I-NEXT: xor a0, a0, a1
14271427
; RV64I-NEXT: subw a0, a0, a1
14281428
; RV64I-NEXT: ret

0 commit comments

Comments
 (0)