[llvm] Fix assertion failure in PR98681 (PR #98860)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 14 23:53:29 PDT 2024
https://github.com/dtcxzyw updated https://github.com/llvm/llvm-project/pull/98860
>From 7930bc6852f2d6b7d8481bfa84c9e0e235cca7b6 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng <dtcxzyw2333 at gmail.com>
Date: Mon, 15 Jul 2024 14:32:53 +0800
Subject: [PATCH 1/2] Fix assertion failure in PR98681
---
llvm/lib/Analysis/ConstantFolding.cpp | 2 +-
llvm/test/Transforms/EarlyCSE/math-2.ll | 10 +++++++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 6c52091cd5d75..df75745645e04 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -2759,7 +2759,7 @@ static Constant *ConstantFoldIntrinsicCall2(Intrinsic::ID IntrinsicID, Type *Ty,
switch (Ty->getTypeID()) {
case Type::HalfTyID:
case Type::FloatTyID: {
- APFloat Res(std::pow(Op1V.convertToFloat(), Exp));
+ APFloat Res(static_cast<float>(std::pow(Op1V.convertToFloat(), Exp)));
if (Ty->isHalfTy()) {
bool Unused;
Res.convert(APFloat::IEEEhalf(), APFloat::rmNearestTiesToEven,
diff --git a/llvm/test/Transforms/EarlyCSE/math-2.ll b/llvm/test/Transforms/EarlyCSE/math-2.ll
index 60a2f19084c83..7e4522a58beaf 100644
--- a/llvm/test/Transforms/EarlyCSE/math-2.ll
+++ b/llvm/test/Transforms/EarlyCSE/math-2.ll
@@ -4,7 +4,7 @@
declare double @atan2(double, double) #0
define double @f_atan2() {
; CHECK-LABEL: @f_atan2(
-; CHECK-NEXT: ret double 0x3FDDAC6{{.+}}
+; CHECK-NEXT: ret double 0x3FDDAC670561BB4F
;
%res = tail call fast double @atan2(double 1.0, double 2.0)
ret double %res
@@ -108,4 +108,12 @@ define half @pr98665() {
ret half %x
}
+define float @powi_f32() {
+; CHECK-LABEL: @powi_f32(
+; CHECK-NEXT: ret float 0.000000e+00
+;
+ %y = call float @llvm.powi.f32.i32(float 0.0, i32 10)
+ ret float %y
+}
+
attributes #0 = { nofree nounwind willreturn }
>From 5fe241bc84931d7975f0640f6b6543b622bf5e8f Mon Sep 17 00:00:00 2001
From: Yingwei Zheng <dtcxzyw at qq.com>
Date: Mon, 15 Jul 2024 14:53:23 +0800
Subject: [PATCH 2/2] Update llvm/test/Transforms/EarlyCSE/math-2.ll
---
llvm/test/Transforms/EarlyCSE/math-2.ll | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/test/Transforms/EarlyCSE/math-2.ll b/llvm/test/Transforms/EarlyCSE/math-2.ll
index 7e4522a58beaf..0d55165e3662f 100644
--- a/llvm/test/Transforms/EarlyCSE/math-2.ll
+++ b/llvm/test/Transforms/EarlyCSE/math-2.ll
@@ -4,7 +4,7 @@
declare double @atan2(double, double) #0
define double @f_atan2() {
; CHECK-LABEL: @f_atan2(
-; CHECK-NEXT: ret double 0x3FDDAC670561BB4F
+; CHECK-NEXT: ret double 0x3FDDAC6{{.+}}
;
%res = tail call fast double @atan2(double 1.0, double 2.0)
ret double %res
More information about the llvm-commits
mailing list