[Constants][PowerPC] Check exactlyValue for ppc_fp128 in isNullValue

PPC_FP128 determines isZero/isNan/isInf using high-order double value
 only. Checking isZero/isNegative might return the isNullValue unexpectedly.
 eg:
   0xM0000000000000000FFFFFFFFFFFFFFFFF

isZero, but it is not NullValue.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D103634
This commit is contained in:
Jinsong Ji 2021-06-03 20:08:35 +00:00
parent a14fc749aa
commit cd9e1a020c
2 changed files with 4 additions and 2 deletions

View file

@ -90,7 +90,9 @@ bool Constant::isNullValue() const {
// +0.0 is null.
if (const ConstantFP *CFP = dyn_cast<ConstantFP>(this))
return CFP->isZero() && !CFP->isNegative();
// ppc_fp128 determine isZero using high order double only
// Should check the bitwise value to make sure all bits are zero.
return CFP->isExactlyValue(+0.0);
// constant zero is zero for aggregates, cpnull is null for pointers, none for
// tokens.

View file

@ -1,7 +1,7 @@
; RUN: llvm-as < %s -o - | llvm-dis - | FileCheck %s
;CHECK-LABEL: main
;CHECK: store ppc_fp128 0xM0000000000000000000000000000000
;CHECK: store ppc_fp128 0xM0000000000000000FFFFFFFFFFFFFFFF
define i32 @main() local_unnamed_addr {
_main_entry: