From ee4414e5a1ff619c37c433e02a701a40ab3d45b0 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Tue, 6 May 2025 19:24:47 +0200 Subject: [PATCH] ValueTracking: Handle minimumnum/maximumnum in canCreateUndefOrPoison --- llvm/lib/Analysis/ValueTracking.cpp | 2 ++ llvm/test/Transforms/InstCombine/freeze-fp-ops.ll | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 256e77b40a97f..cdedc65dd48ad 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -7723,6 +7723,8 @@ static bool canCreateUndefOrPoison(const Operator *Op, UndefPoisonKind Kind, case Intrinsic::maxnum: case Intrinsic::minimum: case Intrinsic::maximum: + case Intrinsic::minimumnum: + case Intrinsic::maximumnum: case Intrinsic::is_fpclass: case Intrinsic::ldexp: case Intrinsic::frexp: diff --git a/llvm/test/Transforms/InstCombine/freeze-fp-ops.ll b/llvm/test/Transforms/InstCombine/freeze-fp-ops.ll index 8bee84f23e147..d1a36dcef4d65 100644 --- a/llvm/test/Transforms/InstCombine/freeze-fp-ops.ll +++ b/llvm/test/Transforms/InstCombine/freeze-fp-ops.ll @@ -508,9 +508,9 @@ define float @freeze_maximum(float %arg0, float noundef %arg1) { define float @freeze_minimumnum(float %arg0, float noundef %arg1) { ; CHECK-LABEL: @freeze_minimumnum( -; CHECK-NEXT: [[OP:%.*]] = call float @llvm.minimumnum.f32(float [[ARG0:%.*]], float noundef [[ARG1:%.*]]) -; CHECK-NEXT: [[FREEZE:%.*]] = freeze float [[OP]] -; CHECK-NEXT: ret float [[FREEZE]] +; CHECK-NEXT: [[FREEZE:%.*]] = freeze float [[OP:%.*]] +; CHECK-NEXT: [[OP1:%.*]] = call float @llvm.minimumnum.f32(float [[FREEZE]], float noundef [[ARG1:%.*]]) +; CHECK-NEXT: ret float [[OP1]] ; %op = call float @llvm.minimumnum.f32(float %arg0, float noundef %arg1) %freeze = freeze float %op @@ -519,9 +519,9 @@ define float @freeze_minimumnum(float %arg0, float noundef %arg1) { define float @freeze_maximumnum(float %arg0, float noundef %arg1) { ; CHECK-LABEL: @freeze_maximumnum( -; CHECK-NEXT: [[OP:%.*]] = call float @llvm.maximumnum.f32(float [[ARG0:%.*]], float noundef [[ARG1:%.*]]) -; CHECK-NEXT: [[FREEZE:%.*]] = freeze float [[OP]] -; CHECK-NEXT: ret float [[FREEZE]] +; CHECK-NEXT: [[FREEZE:%.*]] = freeze float [[OP:%.*]] +; CHECK-NEXT: [[OP1:%.*]] = call float @llvm.maximumnum.f32(float [[FREEZE]], float noundef [[ARG1:%.*]]) +; CHECK-NEXT: ret float [[OP1]] ; %op = call float @llvm.maximumnum.f32(float %arg0, float noundef %arg1) %freeze = freeze float %op