[llvm] [AMDGPU][NFC] Simplify needcopysign logic (PR #75176)

Jakub Chlanda via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 12 04:56:38 PST 2023


https://github.com/jchlanda created https://github.com/llvm/llvm-project/pull/75176

This was caught by coverity, reported as: `dead_error_condition`.
Since the conditional revolves around `CF`, it is guaranteed to be null in the else clause, hence making the second part of the statement redundant.

>From bfa9a6d45afdca6d99f300fc50223e3970ded612 Mon Sep 17 00:00:00 2001
From: Jakub Chlanda <jakub at codeplay.com>
Date: Tue, 12 Dec 2023 11:19:13 +0000
Subject: [PATCH] [AMDGPU][NFC] Simplify needcopysign logic

This was caught by coverity, reported as: `dead_error_condition`.
Since the conditional revolves around `CF`, it is guaranteed to be null
in the else clause, hence making the second part of the statement
redundant.
---
 llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
index 5c66fd2b180f76..fa354cc13d5007 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
@@ -1051,8 +1051,7 @@ bool AMDGPULibCalls::fold_pow(FPMathOperator *FPOp, IRBuilder<> &B,
                      CF->isNegative();
     } else {
       needlog = true;
-      needcopysign = needabs = FInfo.getId() != AMDGPULibFunc::EI_POWR &&
-                               (!CF || CF->isNegative());
+      needcopysign = needabs = FInfo.getId() != AMDGPULibFunc::EI_POWR;
     }
   } else {
     ConstantDataVector *CDV = dyn_cast<ConstantDataVector>(opr0);



More information about the llvm-commits mailing list