Skip to content

[DAG] SelectionDAG::canCreateUndefOrPoison - add ISD::FCOPYSIGN #148617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5620,6 +5620,7 @@ bool SelectionDAG::canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
case ISD::FMUL:
case ISD::FDIV:
case ISD::FREM:
case ISD::FCOPYSIGN:
// No poison except from flags (which is handled above)
return false;

Expand Down
29 changes: 23 additions & 6 deletions llvm/test/CodeGen/PowerPC/copysignl.ll
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ entry:
ret double %conv
}

define double @foo_d_ll_freeze(ppc_fp128 %a, ppc_fp128 %b) #0 {
; CHECK-LABEL: foo_d_ll_freeze:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: fcpsgn 1, 3, 1
; CHECK-NEXT: blr
;
; CHECK-VSX-LABEL: foo_d_ll_freeze:
; CHECK-VSX: # %bb.0: # %entry
; CHECK-VSX-NEXT: xscpsgndp 1, 3, 1
; CHECK-VSX-NEXT: blr
entry:
%call = tail call ppc_fp128 @copysignl(ppc_fp128 %a, ppc_fp128 %b) #0
%freeze = freeze ppc_fp128 %call
%conv = fptrunc ppc_fp128 %freeze to double
ret double %conv
}

declare ppc_fp128 @copysignl(ppc_fp128, ppc_fp128) #0

define double @foo_dl(double %a, ppc_fp128 %b) #0 {
Expand All @@ -46,9 +63,9 @@ define ppc_fp128 @foo_ll(double %a, ppc_fp128 %b) #0 {
; CHECK-NEXT: mflr 0
; CHECK-NEXT: stdu 1, -112(1)
; CHECK-NEXT: fmr 3, 2
; CHECK-NEXT: addis 3, 2, .LCPI2_0@toc@ha
; CHECK-NEXT: addis 3, 2, .LCPI3_0@toc@ha
; CHECK-NEXT: std 0, 128(1)
; CHECK-NEXT: lfs 2, .LCPI2_0@toc@l(3)
; CHECK-NEXT: lfs 2, .LCPI3_0@toc@l(3)
; CHECK-NEXT: bl copysignl
; CHECK-NEXT: nop
; CHECK-NEXT: addi 1, 1, 112
Expand Down Expand Up @@ -81,9 +98,9 @@ define ppc_fp128 @foo_ld(double %a, double %b) #0 {
; CHECK-NEXT: mflr 0
; CHECK-NEXT: stdu 1, -112(1)
; CHECK-NEXT: fmr 3, 2
; CHECK-NEXT: addis 3, 2, .LCPI3_0@toc@ha
; CHECK-NEXT: addis 3, 2, .LCPI4_0@toc@ha
; CHECK-NEXT: std 0, 128(1)
; CHECK-NEXT: lfs 2, .LCPI3_0@toc@l(3)
; CHECK-NEXT: lfs 2, .LCPI4_0@toc@l(3)
; CHECK-NEXT: bl copysignl
; CHECK-NEXT: nop
; CHECK-NEXT: addi 1, 1, 112
Expand Down Expand Up @@ -117,9 +134,9 @@ define ppc_fp128 @foo_lf(double %a, float %b) #0 {
; CHECK-NEXT: mflr 0
; CHECK-NEXT: stdu 1, -112(1)
; CHECK-NEXT: fmr 3, 2
; CHECK-NEXT: addis 3, 2, .LCPI4_0@toc@ha
; CHECK-NEXT: addis 3, 2, .LCPI5_0@toc@ha
; CHECK-NEXT: std 0, 128(1)
; CHECK-NEXT: lfs 2, .LCPI4_0@toc@l(3)
; CHECK-NEXT: lfs 2, .LCPI5_0@toc@l(3)
; CHECK-NEXT: bl copysignl
; CHECK-NEXT: nop
; CHECK-NEXT: addi 1, 1, 112
Expand Down
Loading