[llvm] InstCombine: Add more ldexp by constant tests (PR #171976)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 12 01:05:54 PST 2025
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/171976
None
>From 1a1e7d6eb849e38b0f0090c047e980dd2ab0d196 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Thu, 11 Dec 2025 22:16:12 +0100
Subject: [PATCH] InstCombine: Add more ldexp by constant tests
---
llvm/test/Transforms/InstCombine/ldexp.ll | 80 +++++++++++++++++++++++
1 file changed, 80 insertions(+)
diff --git a/llvm/test/Transforms/InstCombine/ldexp.ll b/llvm/test/Transforms/InstCombine/ldexp.ll
index 8908d476b4a2c..72997eef4fd6d 100644
--- a/llvm/test/Transforms/InstCombine/ldexp.ll
+++ b/llvm/test/Transforms/InstCombine/ldexp.ll
@@ -827,6 +827,86 @@ define float @ldexp_127(float %x) {
ret float %ldexp
}
+define float @ldexp_128(float %x) {
+; CHECK-LABEL: define float @ldexp_128
+; CHECK-SAME: (float [[X:%.*]]) {
+; CHECK-NEXT: [[LDEXP:%.*]] = call float @llvm.ldexp.f32.i32(float [[X]], i32 128)
+; CHECK-NEXT: ret float [[LDEXP]]
+;
+ %ldexp = call float @llvm.ldexp.f32.i32(float %x, i32 128)
+ ret float %ldexp
+}
+
+define float @ldexp_254(float %x) {
+; CHECK-LABEL: define float @ldexp_254
+; CHECK-SAME: (float [[X:%.*]]) {
+; CHECK-NEXT: [[LDEXP:%.*]] = call float @llvm.ldexp.f32.i32(float [[X]], i32 254)
+; CHECK-NEXT: ret float [[LDEXP]]
+;
+ %ldexp = call float @llvm.ldexp.f32.i32(float %x, i32 254)
+ ret float %ldexp
+}
+
+define float @ldexp_255(float %x) {
+; CHECK-LABEL: define float @ldexp_255
+; CHECK-SAME: (float [[X:%.*]]) {
+; CHECK-NEXT: [[LDEXP:%.*]] = call float @llvm.ldexp.f32.i32(float [[X]], i32 255)
+; CHECK-NEXT: ret float [[LDEXP]]
+;
+ %ldexp = call float @llvm.ldexp.f32.i32(float %x, i32 255)
+ ret float %ldexp
+}
+
+define float @ldexp_256(float %x) {
+; CHECK-LABEL: define float @ldexp_256
+; CHECK-SAME: (float [[X:%.*]]) {
+; CHECK-NEXT: [[LDEXP:%.*]] = call float @llvm.ldexp.f32.i32(float [[X]], i32 256)
+; CHECK-NEXT: ret float [[LDEXP]]
+;
+ %ldexp = call float @llvm.ldexp.f32.i32(float %x, i32 256)
+ ret float %ldexp
+}
+
+define float @ldexp_neg254(float %x) {
+; CHECK-LABEL: define float @ldexp_neg254
+; CHECK-SAME: (float [[X:%.*]]) {
+; CHECK-NEXT: [[LDEXP:%.*]] = call float @llvm.ldexp.f32.i32(float [[X]], i32 -254)
+; CHECK-NEXT: ret float [[LDEXP]]
+;
+ %ldexp = call float @llvm.ldexp.f32.i32(float %x, i32 -254)
+ ret float %ldexp
+}
+
+define float @ldexp_neg255(float %x) {
+; CHECK-LABEL: define float @ldexp_neg255
+; CHECK-SAME: (float [[X:%.*]]) {
+; CHECK-NEXT: [[LDEXP:%.*]] = call float @llvm.ldexp.f32.i32(float [[X]], i32 -255)
+; CHECK-NEXT: ret float [[LDEXP]]
+;
+ %ldexp = call float @llvm.ldexp.f32.i32(float %x, i32 -255)
+ ret float %ldexp
+}
+
+define float @ldexp_neg256(float %x) {
+; CHECK-LABEL: define float @ldexp_neg256
+; CHECK-SAME: (float [[X:%.*]]) {
+; CHECK-NEXT: [[LDEXP:%.*]] = call float @llvm.ldexp.f32.i32(float [[X]], i32 -256)
+; CHECK-NEXT: ret float [[LDEXP]]
+;
+ %ldexp = call float @llvm.ldexp.f32.i32(float %x, i32 -256)
+ ret float %ldexp
+}
+
+define float @ldexp_neg260(float %x) {
+; CHECK-LABEL: define float @ldexp_neg260
+; CHECK-SAME: (float [[X:%.*]]) {
+; CHECK-NEXT: [[LDEXP:%.*]] = call float @llvm.ldexp.f32.i32(float [[X]], i32 -260)
+; CHECK-NEXT: ret float [[LDEXP]]
+;
+ %ldexp = call float @llvm.ldexp.f32.i32(float %x, i32 -260)
+ ret float %ldexp
+}
+
define <2 x float> @ldexp_3_vector(<2 x float> %x) {
; CHECK-LABEL: define <2 x float> @ldexp_3_vector
; CHECK-SAME: (<2 x float> [[X:%.*]]) {
More information about the llvm-commits
mailing list