bool IsUndef = match(V, m_Undef());
// If this operation has 'nnan' or 'ninf' and at least 1 disallowed operand
- // (TODO: an undef operand can be chosen to be Nan/Inf), then the result of
+ // (an undef operand can be chosen to be Nan/Inf), then the result of
// this operation is poison. That result can be relaxed to undef.
- if (FMF.noNaNs() && IsNan)
+ if (FMF.noNaNs() && (IsNan || IsUndef))
return UndefValue::get(V->getType());
- if (FMF.noInfs() && IsInf)
+ if (FMF.noInfs() && (IsInf || IsUndef))
return UndefValue::get(V->getType());
if (IsUndef || IsNan)
define float @fadd_undef_op0_nnan(float %x) {
; CHECK-LABEL: @fadd_undef_op0_nnan(
-; CHECK-NEXT: ret float 0x7FF8000000000000
+; CHECK-NEXT: ret float undef
;
%r = fadd nnan float undef, %x
ret float %r
define float @fadd_undef_op1_fast(float %x) {
; CHECK-LABEL: @fadd_undef_op1_fast(
-; CHECK-NEXT: ret float 0x7FF8000000000000
+; CHECK-NEXT: ret float undef
;
%r = fadd fast float %x, undef
ret float %r
define float @fsub_undef_op0_fast(float %x) {
; CHECK-LABEL: @fsub_undef_op0_fast(
-; CHECK-NEXT: ret float 0x7FF8000000000000
+; CHECK-NEXT: ret float undef
;
%r = fsub fast float undef, %x
ret float %r
define float @fsub_undef_op1_nnan(float %x) {
; CHECK-LABEL: @fsub_undef_op1_nnan(
-; CHECK-NEXT: ret float 0x7FF8000000000000
+; CHECK-NEXT: ret float undef
;
%r = fsub nnan float %x, undef
ret float %r
define float @fmul_undef_op0_nnan(float %x) {
; CHECK-LABEL: @fmul_undef_op0_nnan(
-; CHECK-NEXT: ret float 0x7FF8000000000000
+; CHECK-NEXT: ret float undef
;
%r = fmul nnan float undef, %x
ret float %r
define float @fmul_undef_op1_fast(float %x) {
; CHECK-LABEL: @fmul_undef_op1_fast(
-; CHECK-NEXT: ret float 0x7FF8000000000000
+; CHECK-NEXT: ret float undef
;
%r = fmul fast float %x, undef
ret float %r
define float @fdiv_undef_op0_fast(float %x) {
; CHECK-LABEL: @fdiv_undef_op0_fast(
-; CHECK-NEXT: ret float 0x7FF8000000000000
+; CHECK-NEXT: ret float undef
;
%r = fdiv fast float undef, %x
ret float %r
define float @fdiv_undef_op1_nnan(float %x) {
; CHECK-LABEL: @fdiv_undef_op1_nnan(
-; CHECK-NEXT: ret float 0x7FF8000000000000
+; CHECK-NEXT: ret float undef
;
%r = fdiv nnan float %x, undef
ret float %r
define float @frem_undef_op0_nnan(float %x) {
; CHECK-LABEL: @frem_undef_op0_nnan(
-; CHECK-NEXT: ret float 0x7FF8000000000000
+; CHECK-NEXT: ret float undef
;
%r = frem nnan float undef, %x
ret float %r
define float @frem_undef_op1_fast(float %x) {
; CHECK-LABEL: @frem_undef_op1_fast(
-; CHECK-NEXT: ret float 0x7FF8000000000000
+; CHECK-NEXT: ret float undef
;
%r = frem fast float %x, undef
ret float %r