[llvm-branch-commits] [llvm] [Inline] Preserve nofpclass(inf) on returned selects (PR #244343)
Matt Arsenault via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Nov 20 13:51:29 PST 2026
================
@@ -0,0 +1,58 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
+; RUN: opt -S -passes=inline %s | FileCheck %s
+
+define internal float @callee_select(i1 %overflow, i1 %lower, float %normal) alwaysinline {
+ %upper = select i1 %overflow, float +inf, float %normal
+ %result = select i1 %lower, float -1.0, float %upper
+ ret float %result
+}
+
+define float @caller_select_noinf(i1 %overflow, i1 %lower, float %normal) {
+; CHECK-LABEL: define float @caller_select_noinf(
+; CHECK-SAME: i1 [[OVERFLOW:%.*]], i1 [[LOWER:%.*]], float [[NORMAL:%.*]]) {
+; CHECK-NEXT: [[UPPER_I:%.*]] = select i1 [[OVERFLOW]], float +inf, float [[NORMAL]]
+; CHECK-NEXT: [[RESULT_I:%.*]] = select ninf i1 [[LOWER]], float -1.000000e+00, float [[UPPER_I]]
+; CHECK-NEXT: ret float [[RESULT_I]]
+;
+ %value = call nofpclass(inf) float @callee_select(i1 %overflow, i1 %lower, float %normal)
+ ret float %value
+}
+
+define float @caller_select_unrestricted(i1 %overflow, i1 %lower, float %normal) {
+; CHECK-LABEL: define float @caller_select_unrestricted(
+; CHECK-SAME: i1 [[OVERFLOW:%.*]], i1 [[LOWER:%.*]], float [[NORMAL:%.*]]) {
+; CHECK-NEXT: [[UPPER_I:%.*]] = select i1 [[OVERFLOW]], float +inf, float [[NORMAL]]
+; CHECK-NEXT: [[RESULT_I:%.*]] = select i1 [[LOWER]], float -1.000000e+00, float [[UPPER_I]]
+; CHECK-NEXT: ret float [[RESULT_I]]
+;
+ %value = call float @callee_select(i1 %overflow, i1 %lower, float %normal)
+ ret float %value
+}
+
+define float @caller_select_one_inf_class(i1 %overflow, i1 %lower, float %normal) {
+; CHECK-LABEL: define float @caller_select_one_inf_class(
+; CHECK-SAME: i1 [[OVERFLOW:%.*]], i1 [[LOWER:%.*]], float [[NORMAL:%.*]]) {
+; CHECK-NEXT: [[UPPER_I:%.*]] = select i1 [[OVERFLOW]], float +inf, float [[NORMAL]]
+; CHECK-NEXT: [[RESULT_I:%.*]] = select i1 [[LOWER]], float -1.000000e+00, float [[UPPER_I]]
+; CHECK-NEXT: ret float [[RESULT_I]]
+;
+ %value = call nofpclass(pinf) float @callee_select(i1 %overflow, i1 %lower, float %normal)
+ ret float %value
+}
+
+define internal float @callee_select_with_store(i1 %overflow, float %normal, ptr %out) alwaysinline {
+ %result = select i1 %overflow, float +inf, float %normal
+ store float %result, ptr %out
+ ret float %result
+}
+
+define float @caller_select_shared_result(i1 %overflow, float %normal, ptr %out) {
+; CHECK-LABEL: define float @caller_select_shared_result(
+; CHECK-SAME: i1 [[OVERFLOW:%.*]], float [[NORMAL:%.*]], ptr [[OUT:%.*]]) {
+; CHECK-NEXT: [[RESULT_I:%.*]] = select i1 [[OVERFLOW]], float +inf, float [[NORMAL]]
+; CHECK-NEXT: store float [[RESULT_I]], ptr [[OUT]], align 4
+; CHECK-NEXT: ret float [[RESULT_I]]
+;
+ %value = call nofpclass(inf) float @callee_select_with_store(i1 %overflow, float %normal, ptr %out)
+ ret float %value
+}
----------------
arsenm wrote:
Multiple return cases not tested
https://github.com/llvm/llvm-project/pull/244343
More information about the llvm-branch-commits
mailing list