[llvm] a66dc75 - [InstSimplify] simplify FP ops harder with FMF (part 2)
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 12 06:53:27 PDT 2020
Author: Sanjay Patel
Date: 2020-03-12T09:53:20-04:00
New Revision: a66dc755db4cd0af678b0dd7a84ca64fd66518f6
URL: https://github.com/llvm/llvm-project/commit/a66dc755db4cd0af678b0dd7a84ca64fd66518f6
DIFF: https://github.com/llvm/llvm-project/commit/a66dc755db4cd0af678b0dd7a84ca64fd66518f6.diff
LOG: [InstSimplify] simplify FP ops harder with FMF (part 2)
This is part of the IR sibling for:
D75576
Related transform committed with:
rG8ec71585719d
Added:
Modified:
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/fp-undef.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 6144618003d8..de7310623e84 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4611,11 +4611,11 @@ static Constant *simplifyFPOp(ArrayRef<Value *> Ops,
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)
diff --git a/llvm/test/Transforms/InstSimplify/fp-undef.ll b/llvm/test/Transforms/InstSimplify/fp-undef.ll
index cdf887f33639..7b11955d9b35 100644
--- a/llvm/test/Transforms/InstSimplify/fp-undef.ll
+++ b/llvm/test/Transforms/InstSimplify/fp-undef.ll
@@ -85,7 +85,7 @@ define float @frem_undef_op1(float %x) {
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
@@ -93,7 +93,7 @@ define float @fadd_undef_op0_nnan(float %x) {
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
@@ -101,7 +101,7 @@ define float @fadd_undef_op1_fast(float %x) {
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
@@ -109,7 +109,7 @@ define float @fsub_undef_op0_fast(float %x) {
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
@@ -117,7 +117,7 @@ define float @fsub_undef_op1_nnan(float %x) {
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
@@ -125,7 +125,7 @@ define float @fmul_undef_op0_nnan(float %x) {
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
@@ -133,7 +133,7 @@ define float @fmul_undef_op1_fast(float %x) {
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
@@ -141,7 +141,7 @@ define float @fdiv_undef_op0_fast(float %x) {
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
@@ -149,7 +149,7 @@ define float @fdiv_undef_op1_nnan(float %x) {
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
@@ -157,7 +157,7 @@ define float @frem_undef_op0_nnan(float %x) {
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
More information about the llvm-commits
mailing list