Skip to content

Commit 296e057

Browse files
Seraphimtarsenm
andauthored
[DAG] SelectionDAG::canCreateUndefOrPoison - add ISD::FMA/FMAD + tests (#152187)
In SelectionDAG::canCreateUndefOrPoison add case ISD::FMA/FMAD + tests. Fixing #147693 --------- Co-authored-by: Matt Arsenault <[email protected]>
1 parent d0c9599 commit 296e057

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5628,6 +5628,8 @@ bool SelectionDAG::canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
56285628
case ISD::FDIV:
56295629
case ISD::FREM:
56305630
case ISD::FCOPYSIGN:
5631+
case ISD::FMA:
5632+
case ISD::FMAD:
56315633
case ISD::FP_EXTEND:
56325634
// No poison except from flags (which is handled above)
56335635
return false;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc < %s -mtriple=aarch64-- | FileCheck %s --check-prefixes=CHECK
3+
4+
define float @positive_case_fma(float %a0, float %a1, float %a2) {
5+
; CHECK-LABEL: positive_case_fma:
6+
; CHECK: // %bb.0:
7+
; CHECK-NEXT: fnmadd s0, s0, s1, s2
8+
; CHECK-NEXT: ret
9+
%fma = call float @llvm.fma.f32(float %a0, float %a1, float %a2)
10+
%freeze = freeze float %fma
11+
%fneg = fneg float %freeze
12+
ret float %fneg
13+
}
14+
15+
define float @negative_case_fma(float %a0, float %a1) {
16+
; CHECK-LABEL: negative_case_fma:
17+
; CHECK: // %bb.0:
18+
; CHECK-NEXT: fnmadd s0, s0, s1, s0
19+
; CHECK-NEXT: ret
20+
%fma = call float @llvm.fma.f32(float %a0, float %a1, float poison)
21+
%freeze = freeze float %fma
22+
%fneg = fneg float %freeze
23+
ret float %fneg
24+
}
25+
26+
define float @positive_case_fmad(float %a0, float %a1, float %a2) {
27+
; CHECK-LABEL: positive_case_fmad:
28+
; CHECK: // %bb.0:
29+
; CHECK-NEXT: fnmadd s0, s0, s1, s2
30+
; CHECK-NEXT: ret
31+
%fma = call float @llvm.fma.f32(float %a0, float %a1, float %a2)
32+
%freeze = freeze float %fma
33+
%fneg = fneg float %freeze
34+
ret float %fneg
35+
}
36+
37+
define float @negative_case_fmad(float %a0, float %a1) {
38+
; CHECK-LABEL: negative_case_fmad:
39+
; CHECK: // %bb.0:
40+
; CHECK-NEXT: fnmadd s0, s0, s1, s0
41+
; CHECK-NEXT: ret
42+
%fmad = call float @llvm.fmuladd.f32(float %a0, float %a1, float poison)
43+
%freeze = freeze float %fmad
44+
%fneg = fneg float %freeze
45+
ret float %fneg
46+
}
47+

0 commit comments

Comments
 (0)