Skip to content

Commit 4a2a0aa

Browse files
committed
[InstCombine] Canonicalize (sitofp x) -> (uitofp x) if x >= 0
Just a standard canonicalization. Proofs: https://alive2.llvm.org/ce/z/9W4VFm
1 parent f95a763 commit 4a2a0aa

File tree

10 files changed

+90
-89
lines changed

10 files changed

+90
-89
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1938,7 +1938,11 @@ Instruction *InstCombinerImpl::visitUIToFP(CastInst &CI) {
19381938
}
19391939

19401940
Instruction *InstCombinerImpl::visitSIToFP(CastInst &CI) {
1941-
return commonCastTransforms(CI);
1941+
if (Instruction *R = commonCastTransforms(CI))
1942+
return R;
1943+
if (isKnownNonNegative(CI.getOperand(0), SQ))
1944+
return new UIToFPInst(CI.getOperand(0), CI.getType());
1945+
return nullptr;
19421946
}
19431947

19441948
Instruction *InstCombinerImpl::visitIntToPtr(IntToPtrInst &CI) {

llvm/test/Transforms/InstCombine/add-sitofp.ll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ define double @x(i32 %a, i32 %b) {
66
; CHECK-NEXT: [[M:%.*]] = lshr i32 [[A:%.*]], 24
77
; CHECK-NEXT: [[N:%.*]] = and i32 [[M]], [[B:%.*]]
88
; CHECK-NEXT: [[TMP1:%.*]] = add nuw nsw i32 [[N]], 1
9-
; CHECK-NEXT: [[P:%.*]] = sitofp i32 [[TMP1]] to double
9+
; CHECK-NEXT: [[P:%.*]] = uitofp i32 [[TMP1]] to double
1010
; CHECK-NEXT: ret double [[P]]
1111
;
1212
%m = lshr i32 %a, 24
@@ -20,7 +20,7 @@ define double @test(i32 %a) {
2020
; CHECK-LABEL: @test(
2121
; CHECK-NEXT: [[A_AND:%.*]] = and i32 [[A:%.*]], 1073741823
2222
; CHECK-NEXT: [[TMP1:%.*]] = add nuw nsw i32 [[A_AND]], 1
23-
; CHECK-NEXT: [[RES:%.*]] = sitofp i32 [[TMP1]] to double
23+
; CHECK-NEXT: [[RES:%.*]] = uitofp i32 [[TMP1]] to double
2424
; CHECK-NEXT: ret double [[RES]]
2525
;
2626
; Drop two highest bits to guarantee that %a + 1 doesn't overflow
@@ -33,7 +33,7 @@ define double @test(i32 %a) {
3333
define float @test_neg(i32 %a) {
3434
; CHECK-LABEL: @test_neg(
3535
; CHECK-NEXT: [[A_AND:%.*]] = and i32 [[A:%.*]], 1073741823
36-
; CHECK-NEXT: [[A_AND_FP:%.*]] = sitofp i32 [[A_AND]] to float
36+
; CHECK-NEXT: [[A_AND_FP:%.*]] = uitofp i32 [[A_AND]] to float
3737
; CHECK-NEXT: [[RES:%.*]] = fadd float [[A_AND_FP]], 1.000000e+00
3838
; CHECK-NEXT: ret float [[RES]]
3939
;
@@ -49,7 +49,7 @@ define double @test_2(i32 %a, i32 %b) {
4949
; CHECK-NEXT: [[A_AND:%.*]] = and i32 [[A:%.*]], 1073741823
5050
; CHECK-NEXT: [[B_AND:%.*]] = and i32 [[B:%.*]], 1073741823
5151
; CHECK-NEXT: [[TMP1:%.*]] = add nuw nsw i32 [[A_AND]], [[B_AND]]
52-
; CHECK-NEXT: [[RES:%.*]] = sitofp i32 [[TMP1]] to double
52+
; CHECK-NEXT: [[RES:%.*]] = uitofp i32 [[TMP1]] to double
5353
; CHECK-NEXT: ret double [[RES]]
5454
;
5555
; Drop two highest bits to guarantee that %a + %b doesn't overflow
@@ -67,8 +67,8 @@ define float @test_2_neg(i32 %a, i32 %b) {
6767
; CHECK-LABEL: @test_2_neg(
6868
; CHECK-NEXT: [[A_AND:%.*]] = and i32 [[A:%.*]], 1073741823
6969
; CHECK-NEXT: [[B_AND:%.*]] = and i32 [[B:%.*]], 1073741823
70-
; CHECK-NEXT: [[A_AND_FP:%.*]] = sitofp i32 [[A_AND]] to float
71-
; CHECK-NEXT: [[B_AND_FP:%.*]] = sitofp i32 [[B_AND]] to float
70+
; CHECK-NEXT: [[A_AND_FP:%.*]] = uitofp i32 [[A_AND]] to float
71+
; CHECK-NEXT: [[B_AND_FP:%.*]] = uitofp i32 [[B_AND]] to float
7272
; CHECK-NEXT: [[RES:%.*]] = fadd float [[A_AND_FP]], [[B_AND_FP]]
7373
; CHECK-NEXT: ret float [[RES]]
7474
;
@@ -89,7 +89,7 @@ define float @test_3(i32 %a, i32 %b) {
8989
; CHECK-NEXT: [[M:%.*]] = lshr i32 [[A:%.*]], 24
9090
; CHECK-NEXT: [[N:%.*]] = and i32 [[M]], [[B:%.*]]
9191
; CHECK-NEXT: [[TMP1:%.*]] = add nuw nsw i32 [[N]], 1
92-
; CHECK-NEXT: [[P:%.*]] = sitofp i32 [[TMP1]] to float
92+
; CHECK-NEXT: [[P:%.*]] = uitofp i32 [[TMP1]] to float
9393
; CHECK-NEXT: ret float [[P]]
9494
;
9595
%m = lshr i32 %a, 24
@@ -104,7 +104,7 @@ define <4 x double> @test_4(<4 x i32> %a, <4 x i32> %b) {
104104
; CHECK-NEXT: [[A_AND:%.*]] = and <4 x i32> [[A:%.*]], <i32 1073741823, i32 1073741823, i32 1073741823, i32 1073741823>
105105
; CHECK-NEXT: [[B_AND:%.*]] = and <4 x i32> [[B:%.*]], <i32 1073741823, i32 1073741823, i32 1073741823, i32 1073741823>
106106
; CHECK-NEXT: [[TMP1:%.*]] = add nuw nsw <4 x i32> [[A_AND]], [[B_AND]]
107-
; CHECK-NEXT: [[RES:%.*]] = sitofp <4 x i32> [[TMP1]] to <4 x double>
107+
; CHECK-NEXT: [[RES:%.*]] = uitofp <4 x i32> [[TMP1]] to <4 x double>
108108
; CHECK-NEXT: ret <4 x double> [[RES]]
109109
;
110110
; Drop two highest bits to guarantee that %a + %b doesn't overflow
@@ -122,8 +122,8 @@ define <4 x float> @test_4_neg(<4 x i32> %a, <4 x i32> %b) {
122122
; CHECK-LABEL: @test_4_neg(
123123
; CHECK-NEXT: [[A_AND:%.*]] = and <4 x i32> [[A:%.*]], <i32 1073741823, i32 1073741823, i32 1073741823, i32 1073741823>
124124
; CHECK-NEXT: [[B_AND:%.*]] = and <4 x i32> [[B:%.*]], <i32 1073741823, i32 1073741823, i32 1073741823, i32 1073741823>
125-
; CHECK-NEXT: [[A_AND_FP:%.*]] = sitofp <4 x i32> [[A_AND]] to <4 x float>
126-
; CHECK-NEXT: [[B_AND_FP:%.*]] = sitofp <4 x i32> [[B_AND]] to <4 x float>
125+
; CHECK-NEXT: [[A_AND_FP:%.*]] = uitofp <4 x i32> [[A_AND]] to <4 x float>
126+
; CHECK-NEXT: [[B_AND_FP:%.*]] = uitofp <4 x i32> [[B_AND]] to <4 x float>
127127
; CHECK-NEXT: [[RES:%.*]] = fadd <4 x float> [[A_AND_FP]], [[B_AND_FP]]
128128
; CHECK-NEXT: ret <4 x float> [[RES]]
129129
;

llvm/test/Transforms/InstCombine/binop-itofp.ll

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ define half @test_ui_si_i8_add(i8 noundef %x_in, i8 noundef %y_in) {
110110
; CHECK-NEXT: [[X:%.*]] = and i8 [[X_IN:%.*]], 63
111111
; CHECK-NEXT: [[Y:%.*]] = and i8 [[Y_IN:%.*]], 63
112112
; CHECK-NEXT: [[TMP1:%.*]] = add nuw nsw i8 [[X]], [[Y]]
113-
; CHECK-NEXT: [[R:%.*]] = sitofp i8 [[TMP1]] to half
113+
; CHECK-NEXT: [[R:%.*]] = uitofp i8 [[TMP1]] to half
114114
; CHECK-NEXT: ret half [[R]]
115115
;
116116
%x = and i8 %x_in, 63
@@ -125,9 +125,8 @@ define half @test_ui_si_i8_add_overflow(i8 noundef %x_in, i8 noundef %y_in) {
125125
; CHECK-LABEL: @test_ui_si_i8_add_overflow(
126126
; CHECK-NEXT: [[X:%.*]] = and i8 [[X_IN:%.*]], 63
127127
; CHECK-NEXT: [[Y:%.*]] = and i8 [[Y_IN:%.*]], 65
128-
; CHECK-NEXT: [[XF:%.*]] = sitofp i8 [[X]] to half
129-
; CHECK-NEXT: [[YF:%.*]] = uitofp i8 [[Y]] to half
130-
; CHECK-NEXT: [[R:%.*]] = fadd half [[XF]], [[YF]]
128+
; CHECK-NEXT: [[TMP1:%.*]] = add nuw i8 [[X]], [[Y]]
129+
; CHECK-NEXT: [[R:%.*]] = uitofp i8 [[TMP1]] to half
131130
; CHECK-NEXT: ret half [[R]]
132131
;
133132
%x = and i8 %x_in, 63
@@ -168,7 +167,7 @@ define half @test_si_si_i8_sub(i8 noundef %x_in, i8 noundef %y_in) {
168167
; CHECK-NEXT: [[X:%.*]] = and i8 [[X_IN:%.*]], 63
169168
; CHECK-NEXT: [[Y:%.*]] = or i8 [[Y_IN:%.*]], -64
170169
; CHECK-NEXT: [[TMP1:%.*]] = sub nsw i8 [[X]], [[Y]]
171-
; CHECK-NEXT: [[R:%.*]] = sitofp i8 [[TMP1]] to half
170+
; CHECK-NEXT: [[R:%.*]] = uitofp i8 [[TMP1]] to half
172171
; CHECK-NEXT: ret half [[R]]
173172
;
174173
%x = and i8 %x_in, 63
@@ -183,7 +182,7 @@ define half @test_si_si_i8_sub_fail_overflow(i8 noundef %x_in, i8 noundef %y_in)
183182
; CHECK-LABEL: @test_si_si_i8_sub_fail_overflow(
184183
; CHECK-NEXT: [[X:%.*]] = and i8 [[X_IN:%.*]], 63
185184
; CHECK-NEXT: [[Y:%.*]] = or i8 [[Y_IN:%.*]], -65
186-
; CHECK-NEXT: [[XF:%.*]] = sitofp i8 [[X]] to half
185+
; CHECK-NEXT: [[XF:%.*]] = uitofp i8 [[X]] to half
187186
; CHECK-NEXT: [[YF:%.*]] = sitofp i8 [[Y]] to half
188187
; CHECK-NEXT: [[R:%.*]] = fsub half [[XF]], [[YF]]
189188
; CHECK-NEXT: ret half [[R]]
@@ -200,7 +199,7 @@ define half @test_si_si_i8_sub_C(i8 noundef %x_in) {
200199
; CHECK-LABEL: @test_si_si_i8_sub_C(
201200
; CHECK-NEXT: [[X:%.*]] = and i8 [[X_IN:%.*]], 63
202201
; CHECK-NEXT: [[TMP1:%.*]] = or disjoint i8 [[X]], 64
203-
; CHECK-NEXT: [[R:%.*]] = sitofp i8 [[TMP1]] to half
202+
; CHECK-NEXT: [[R:%.*]] = uitofp i8 [[TMP1]] to half
204203
; CHECK-NEXT: ret half [[R]]
205204
;
206205
%x = and i8 %x_in, 63
@@ -212,8 +211,8 @@ define half @test_si_si_i8_sub_C(i8 noundef %x_in) {
212211
define half @test_si_si_i8_sub_C_fail_overflow(i8 noundef %x_in) {
213212
; CHECK-LABEL: @test_si_si_i8_sub_C_fail_overflow(
214213
; CHECK-NEXT: [[X:%.*]] = and i8 [[X_IN:%.*]], 65
215-
; CHECK-NEXT: [[XF:%.*]] = sitofp i8 [[X]] to half
216-
; CHECK-NEXT: [[R:%.*]] = fadd half [[XF]], 0xH5400
214+
; CHECK-NEXT: [[TMP1:%.*]] = add nuw i8 [[X]], 64
215+
; CHECK-NEXT: [[R:%.*]] = uitofp i8 [[TMP1]] to half
217216
; CHECK-NEXT: ret half [[R]]
218217
;
219218
%x = and i8 %x_in, 65
@@ -242,9 +241,8 @@ define half @test_ui_si_i8_sub_fail_maybe_sign(i8 noundef %x_in, i8 noundef %y_i
242241
; CHECK-LABEL: @test_ui_si_i8_sub_fail_maybe_sign(
243242
; CHECK-NEXT: [[X:%.*]] = or i8 [[X_IN:%.*]], 64
244243
; CHECK-NEXT: [[Y:%.*]] = and i8 [[Y_IN:%.*]], 63
245-
; CHECK-NEXT: [[XF:%.*]] = uitofp i8 [[X]] to half
246-
; CHECK-NEXT: [[YF:%.*]] = sitofp i8 [[Y]] to half
247-
; CHECK-NEXT: [[R:%.*]] = fsub half [[XF]], [[YF]]
244+
; CHECK-NEXT: [[TMP1:%.*]] = sub nuw nsw i8 [[X]], [[Y]]
245+
; CHECK-NEXT: [[R:%.*]] = uitofp i8 [[TMP1]] to half
248246
; CHECK-NEXT: ret half [[R]]
249247
;
250248
%x = or i8 %x_in, 64
@@ -273,8 +271,8 @@ define half @test_ui_ui_i8_mul(i8 noundef %x_in, i8 noundef %y_in) {
273271

274272
define half @test_ui_ui_i8_mul_C(i8 noundef %x_in) {
275273
; CHECK-LABEL: @test_ui_ui_i8_mul_C(
276-
; CHECK-NEXT: [[TMP1:%.*]] = shl i8 [[X_IN:%.*]], 4
277-
; CHECK-NEXT: [[R:%.*]] = uitofp i8 [[TMP1]] to half
274+
; CHECK-NEXT: [[X:%.*]] = shl i8 [[X_IN:%.*]], 4
275+
; CHECK-NEXT: [[R:%.*]] = uitofp i8 [[X]] to half
278276
; CHECK-NEXT: ret half [[R]]
279277
;
280278
%x = and i8 %x_in, 15
@@ -318,7 +316,7 @@ define half @test_si_si_i8_mul_fail_maybe_zero(i8 noundef %x_in, i8 noundef %y_i
318316
; CHECK-LABEL: @test_si_si_i8_mul_fail_maybe_zero(
319317
; CHECK-NEXT: [[X:%.*]] = and i8 [[X_IN:%.*]], 7
320318
; CHECK-NEXT: [[Y:%.*]] = or i8 [[Y_IN:%.*]], -8
321-
; CHECK-NEXT: [[XF:%.*]] = sitofp i8 [[X]] to half
319+
; CHECK-NEXT: [[XF:%.*]] = uitofp i8 [[X]] to half
322320
; CHECK-NEXT: [[YF:%.*]] = sitofp i8 [[Y]] to half
323321
; CHECK-NEXT: [[R:%.*]] = fmul half [[XF]], [[YF]]
324322
; CHECK-NEXT: ret half [[R]]
@@ -335,7 +333,7 @@ define half @test_si_si_i8_mul_C_fail_no_repr(i8 noundef %x_in) {
335333
; CHECK-LABEL: @test_si_si_i8_mul_C_fail_no_repr(
336334
; CHECK-NEXT: [[XX:%.*]] = and i8 [[X_IN:%.*]], 6
337335
; CHECK-NEXT: [[X:%.*]] = or disjoint i8 [[XX]], 1
338-
; CHECK-NEXT: [[XF:%.*]] = sitofp i8 [[X]] to half
336+
; CHECK-NEXT: [[XF:%.*]] = uitofp i8 [[X]] to half
339337
; CHECK-NEXT: [[R:%.*]] = fmul half [[XF]], 0xHC780
340338
; CHECK-NEXT: ret half [[R]]
341339
;
@@ -350,7 +348,7 @@ define half @test_si_si_i8_mul_C_fail_overflow(i8 noundef %x_in) {
350348
; CHECK-LABEL: @test_si_si_i8_mul_C_fail_overflow(
351349
; CHECK-NEXT: [[XX:%.*]] = and i8 [[X_IN:%.*]], 6
352350
; CHECK-NEXT: [[X:%.*]] = or disjoint i8 [[XX]], 1
353-
; CHECK-NEXT: [[XF:%.*]] = sitofp i8 [[X]] to half
351+
; CHECK-NEXT: [[XF:%.*]] = uitofp i8 [[X]] to half
354352
; CHECK-NEXT: [[R:%.*]] = fmul half [[XF]], 0xHCCC0
355353
; CHECK-NEXT: ret half [[R]]
356354
;
@@ -368,7 +366,7 @@ define half @test_ui_si_i8_mul(i8 noundef %x_in, i8 noundef %y_in) {
368366
; CHECK-NEXT: [[YY:%.*]] = and i8 [[Y_IN:%.*]], 7
369367
; CHECK-NEXT: [[Y:%.*]] = add nuw nsw i8 [[YY]], 1
370368
; CHECK-NEXT: [[TMP1:%.*]] = mul nuw nsw i8 [[X]], [[Y]]
371-
; CHECK-NEXT: [[R:%.*]] = sitofp i8 [[TMP1]] to half
369+
; CHECK-NEXT: [[R:%.*]] = uitofp i8 [[TMP1]] to half
372370
; CHECK-NEXT: ret half [[R]]
373371
;
374372
%xx = and i8 %x_in, 6
@@ -386,9 +384,8 @@ define half @test_ui_si_i8_mul_fail_maybe_zero(i8 noundef %x_in, i8 noundef %y_i
386384
; CHECK-NEXT: [[XX:%.*]] = and i8 [[X_IN:%.*]], 7
387385
; CHECK-NEXT: [[X:%.*]] = add nuw nsw i8 [[XX]], 1
388386
; CHECK-NEXT: [[Y:%.*]] = and i8 [[Y_IN:%.*]], 7
389-
; CHECK-NEXT: [[XF:%.*]] = sitofp i8 [[X]] to half
390-
; CHECK-NEXT: [[YF:%.*]] = uitofp i8 [[Y]] to half
391-
; CHECK-NEXT: [[R:%.*]] = fmul half [[XF]], [[YF]]
387+
; CHECK-NEXT: [[TMP1:%.*]] = mul nuw nsw i8 [[X]], [[Y]]
388+
; CHECK-NEXT: [[R:%.*]] = uitofp i8 [[TMP1]] to half
392389
; CHECK-NEXT: ret half [[R]]
393390
;
394391
%xx = and i8 %x_in, 7
@@ -405,7 +402,7 @@ define half @test_ui_si_i8_mul_fail_signed(i8 noundef %x_in, i8 noundef %y_in) {
405402
; CHECK-NEXT: [[XX:%.*]] = and i8 [[X_IN:%.*]], 7
406403
; CHECK-NEXT: [[X:%.*]] = add nuw nsw i8 [[XX]], 1
407404
; CHECK-NEXT: [[Y:%.*]] = or i8 [[Y_IN:%.*]], -4
408-
; CHECK-NEXT: [[XF:%.*]] = sitofp i8 [[X]] to half
405+
; CHECK-NEXT: [[XF:%.*]] = uitofp i8 [[X]] to half
409406
; CHECK-NEXT: [[YF:%.*]] = uitofp i8 [[Y]] to half
410407
; CHECK-NEXT: [[R:%.*]] = fmul half [[XF]], [[YF]]
411408
; CHECK-NEXT: ret half [[R]]
@@ -545,7 +542,7 @@ define half @test_si_si_i16_sub_fail_no_promotion(i16 noundef %x_in, i16 noundef
545542
; CHECK-LABEL: @test_si_si_i16_sub_fail_no_promotion(
546543
; CHECK-NEXT: [[X:%.*]] = and i16 [[X_IN:%.*]], 2047
547544
; CHECK-NEXT: [[Y:%.*]] = or i16 [[Y_IN:%.*]], -2049
548-
; CHECK-NEXT: [[XF:%.*]] = sitofp i16 [[X]] to half
545+
; CHECK-NEXT: [[XF:%.*]] = uitofp i16 [[X]] to half
549546
; CHECK-NEXT: [[YF:%.*]] = sitofp i16 [[Y]] to half
550547
; CHECK-NEXT: [[R:%.*]] = fsub half [[XF]], [[YF]]
551548
; CHECK-NEXT: ret half [[R]]
@@ -579,7 +576,7 @@ define half @test_ui_si_i16_sub_fail_maybe_signed(i16 noundef %x_in, i16 noundef
579576
; CHECK-NEXT: [[X:%.*]] = or i16 [[X_IN:%.*]], -2048
580577
; CHECK-NEXT: [[Y:%.*]] = and i16 [[Y_IN:%.*]], 2047
581578
; CHECK-NEXT: [[XF:%.*]] = uitofp i16 [[X]] to half
582-
; CHECK-NEXT: [[YF:%.*]] = sitofp i16 [[Y]] to half
579+
; CHECK-NEXT: [[YF:%.*]] = uitofp i16 [[Y]] to half
583580
; CHECK-NEXT: [[R:%.*]] = fsub half [[XF]], [[YF]]
584581
; CHECK-NEXT: ret half [[R]]
585582
;
@@ -647,7 +644,7 @@ define half @test_si_si_i16_mul_fail_overflow(i16 noundef %x_in, i16 noundef %y_
647644
; CHECK-NEXT: [[XX:%.*]] = and i16 [[X_IN:%.*]], 126
648645
; CHECK-NEXT: [[X:%.*]] = or disjoint i16 [[XX]], 1
649646
; CHECK-NEXT: [[Y:%.*]] = or i16 [[Y_IN:%.*]], -257
650-
; CHECK-NEXT: [[XF:%.*]] = sitofp i16 [[X]] to half
647+
; CHECK-NEXT: [[XF:%.*]] = uitofp i16 [[X]] to half
651648
; CHECK-NEXT: [[YF:%.*]] = sitofp i16 [[Y]] to half
652649
; CHECK-NEXT: [[R:%.*]] = fmul half [[XF]], [[YF]]
653650
; CHECK-NEXT: ret half [[R]]
@@ -694,7 +691,7 @@ define half @test_ui_si_i16_mul(i16 noundef %x_in, i16 noundef %y_in) {
694691
; CHECK-NEXT: [[YY:%.*]] = and i16 [[Y_IN:%.*]], 126
695692
; CHECK-NEXT: [[Y:%.*]] = or disjoint i16 [[YY]], 1
696693
; CHECK-NEXT: [[TMP1:%.*]] = mul nuw nsw i16 [[X]], [[Y]]
697-
; CHECK-NEXT: [[R:%.*]] = sitofp i16 [[TMP1]] to half
694+
; CHECK-NEXT: [[R:%.*]] = uitofp i16 [[TMP1]] to half
698695
; CHECK-NEXT: ret half [[R]]
699696
;
700697
%xx = and i16 %x_in, 126
@@ -826,7 +823,7 @@ define half @test_si_si_i12_sub(i12 noundef %x_in, i12 noundef %y_in) {
826823
; CHECK-NEXT: [[X:%.*]] = and i12 [[X_IN:%.*]], 1023
827824
; CHECK-NEXT: [[Y:%.*]] = or i12 [[Y_IN:%.*]], -1024
828825
; CHECK-NEXT: [[TMP1:%.*]] = sub nsw i12 [[X]], [[Y]]
829-
; CHECK-NEXT: [[R:%.*]] = sitofp i12 [[TMP1]] to half
826+
; CHECK-NEXT: [[R:%.*]] = uitofp i12 [[TMP1]] to half
830827
; CHECK-NEXT: ret half [[R]]
831828
;
832829
%x = and i12 %x_in, 1023
@@ -920,7 +917,7 @@ define half @test_si_si_i12_mul_fail_overflow(i12 noundef %x_in, i12 noundef %y_
920917
; CHECK-NEXT: [[XX:%.*]] = and i12 [[X_IN:%.*]], 30
921918
; CHECK-NEXT: [[X:%.*]] = or disjoint i12 [[XX]], 1
922919
; CHECK-NEXT: [[Y:%.*]] = or i12 [[Y_IN:%.*]], -128
923-
; CHECK-NEXT: [[XF:%.*]] = sitofp i12 [[X]] to half
920+
; CHECK-NEXT: [[XF:%.*]] = uitofp i12 [[X]] to half
924921
; CHECK-NEXT: [[YF:%.*]] = sitofp i12 [[Y]] to half
925922
; CHECK-NEXT: [[R:%.*]] = fmul half [[XF]], [[YF]]
926923
; CHECK-NEXT: ret half [[R]]
@@ -938,7 +935,7 @@ define half @test_si_si_i12_mul_fail_maybe_non_zero(i12 noundef %x_in, i12 nound
938935
; CHECK-LABEL: @test_si_si_i12_mul_fail_maybe_non_zero(
939936
; CHECK-NEXT: [[X:%.*]] = and i12 [[X_IN:%.*]], 30
940937
; CHECK-NEXT: [[Y:%.*]] = or i12 [[Y_IN:%.*]], -128
941-
; CHECK-NEXT: [[XF:%.*]] = sitofp i12 [[X]] to half
938+
; CHECK-NEXT: [[XF:%.*]] = uitofp i12 [[X]] to half
942939
; CHECK-NEXT: [[YF:%.*]] = sitofp i12 [[Y]] to half
943940
; CHECK-NEXT: [[R:%.*]] = fmul half [[XF]], [[YF]]
944941
; CHECK-NEXT: ret half [[R]]
@@ -955,7 +952,7 @@ define half @test_si_si_i12_mul_C(i12 noundef %x_in) {
955952
; CHECK-LABEL: @test_si_si_i12_mul_C(
956953
; CHECK-NEXT: [[X:%.*]] = or i12 [[X_IN:%.*]], -64
957954
; CHECK-NEXT: [[TMP1:%.*]] = mul nsw i12 [[X]], -16
958-
; CHECK-NEXT: [[R:%.*]] = sitofp i12 [[TMP1]] to half
955+
; CHECK-NEXT: [[R:%.*]] = uitofp i12 [[TMP1]] to half
959956
; CHECK-NEXT: ret half [[R]]
960957
;
961958
%x = or i12 %x_in, -64
@@ -984,7 +981,7 @@ define half @test_ui_si_i12_mul_nsw(i12 noundef %x_in, i12 noundef %y_in) {
984981
; CHECK-NEXT: [[YY:%.*]] = and i12 [[Y_IN:%.*]], 30
985982
; CHECK-NEXT: [[Y:%.*]] = or disjoint i12 [[YY]], 1
986983
; CHECK-NEXT: [[TMP1:%.*]] = mul nuw nsw i12 [[X]], [[Y]]
987-
; CHECK-NEXT: [[R:%.*]] = sitofp i12 [[TMP1]] to half
984+
; CHECK-NEXT: [[R:%.*]] = uitofp i12 [[TMP1]] to half
988985
; CHECK-NEXT: ret half [[R]]
989986
;
990987
%xx = and i12 %x_in, 31

llvm/test/Transforms/InstCombine/clamp-to-minmax.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ define float @mixed_clamp_to_float_1(i32 %x) {
504504
; CHECK-LABEL: @mixed_clamp_to_float_1(
505505
; CHECK-NEXT: [[SI_MIN:%.*]] = call i32 @llvm.smin.i32(i32 [[X:%.*]], i32 255)
506506
; CHECK-NEXT: [[R1:%.*]] = call i32 @llvm.smax.i32(i32 [[SI_MIN]], i32 1)
507-
; CHECK-NEXT: [[R:%.*]] = sitofp i32 [[R1]] to float
507+
; CHECK-NEXT: [[R:%.*]] = uitofp i32 [[R1]] to float
508508
; CHECK-NEXT: ret float [[R]]
509509
;
510510
%si_min_cmp = icmp sgt i32 %x, 255
@@ -539,7 +539,7 @@ define float @mixed_clamp_to_float_2(i32 %x) {
539539
; CHECK-LABEL: @mixed_clamp_to_float_2(
540540
; CHECK-NEXT: [[SI_MIN:%.*]] = call i32 @llvm.smin.i32(i32 [[X:%.*]], i32 255)
541541
; CHECK-NEXT: [[R1:%.*]] = call i32 @llvm.smax.i32(i32 [[SI_MIN]], i32 1)
542-
; CHECK-NEXT: [[R:%.*]] = sitofp i32 [[R1]] to float
542+
; CHECK-NEXT: [[R:%.*]] = uitofp i32 [[R1]] to float
543543
; CHECK-NEXT: ret float [[R]]
544544
;
545545
%si_min_cmp = icmp sgt i32 %x, 255
@@ -572,7 +572,7 @@ define <2 x float> @mixed_clamp_to_float_vec(<2 x i32> %x) {
572572
; CHECK-LABEL: @mixed_clamp_to_float_vec(
573573
; CHECK-NEXT: [[SI_MIN:%.*]] = call <2 x i32> @llvm.smin.v2i32(<2 x i32> [[X:%.*]], <2 x i32> <i32 255, i32 255>)
574574
; CHECK-NEXT: [[R1:%.*]] = call <2 x i32> @llvm.smax.v2i32(<2 x i32> [[SI_MIN]], <2 x i32> <i32 1, i32 1>)
575-
; CHECK-NEXT: [[R:%.*]] = sitofp <2 x i32> [[R1]] to <2 x float>
575+
; CHECK-NEXT: [[R:%.*]] = uitofp <2 x i32> [[R1]] to <2 x float>
576576
; CHECK-NEXT: ret <2 x float> [[R]]
577577
;
578578
%si_min_cmp = icmp sgt <2 x i32> %x, <i32 255, i32 255>

llvm/test/Transforms/InstCombine/fpcast.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ define half @sint_to_fptrunc(i32 %x) {
170170
define half @masked_sint_to_fptrunc1(i32 %x) {
171171
; CHECK-LABEL: @masked_sint_to_fptrunc1(
172172
; CHECK-NEXT: [[M:%.*]] = and i32 [[X:%.*]], 16777215
173-
; CHECK-NEXT: [[R:%.*]] = sitofp i32 [[M]] to half
173+
; CHECK-NEXT: [[R:%.*]] = uitofp i32 [[M]] to half
174174
; CHECK-NEXT: ret half [[R]]
175175
;
176176
%m = and i32 %x, 16777215
@@ -182,7 +182,7 @@ define half @masked_sint_to_fptrunc1(i32 %x) {
182182
define half @masked_sint_to_fptrunc2(i32 %x) {
183183
; CHECK-LABEL: @masked_sint_to_fptrunc2(
184184
; CHECK-NEXT: [[M:%.*]] = lshr i32 [[X:%.*]], 8
185-
; CHECK-NEXT: [[R:%.*]] = sitofp i32 [[M]] to half
185+
; CHECK-NEXT: [[R:%.*]] = uitofp i32 [[M]] to half
186186
; CHECK-NEXT: ret half [[R]]
187187
;
188188
%m = lshr i32 %x, 8
@@ -194,7 +194,7 @@ define half @masked_sint_to_fptrunc2(i32 %x) {
194194
define half @masked_sint_to_fptrunc3(i32 %x) {
195195
; CHECK-LABEL: @masked_sint_to_fptrunc3(
196196
; CHECK-NEXT: [[M:%.*]] = lshr i32 [[X:%.*]], 7
197-
; CHECK-NEXT: [[F:%.*]] = sitofp i32 [[M]] to float
197+
; CHECK-NEXT: [[F:%.*]] = uitofp i32 [[M]] to float
198198
; CHECK-NEXT: [[R:%.*]] = fptrunc float [[F]] to half
199199
; CHECK-NEXT: ret half [[R]]
200200
;
@@ -218,7 +218,7 @@ define double @sint_to_fpext(i32 %x) {
218218
define double @masked_sint_to_fpext1(i32 %x) {
219219
; CHECK-LABEL: @masked_sint_to_fpext1(
220220
; CHECK-NEXT: [[M:%.*]] = and i32 [[X:%.*]], 16777215
221-
; CHECK-NEXT: [[R:%.*]] = sitofp i32 [[M]] to double
221+
; CHECK-NEXT: [[R:%.*]] = uitofp i32 [[M]] to double
222222
; CHECK-NEXT: ret double [[R]]
223223
;
224224
%m = and i32 %x, 16777215
@@ -230,7 +230,7 @@ define double @masked_sint_to_fpext1(i32 %x) {
230230
define double @masked_sint_to_fpext2(i32 %x) {
231231
; CHECK-LABEL: @masked_sint_to_fpext2(
232232
; CHECK-NEXT: [[M:%.*]] = lshr i32 [[X:%.*]], 8
233-
; CHECK-NEXT: [[R:%.*]] = sitofp i32 [[M]] to double
233+
; CHECK-NEXT: [[R:%.*]] = uitofp i32 [[M]] to double
234234
; CHECK-NEXT: ret double [[R]]
235235
;
236236
%m = lshr i32 %x, 8
@@ -242,7 +242,7 @@ define double @masked_sint_to_fpext2(i32 %x) {
242242
define double @masked_sint_to_fpext3(i32 %x) {
243243
; CHECK-LABEL: @masked_sint_to_fpext3(
244244
; CHECK-NEXT: [[M:%.*]] = lshr i32 [[X:%.*]], 7
245-
; CHECK-NEXT: [[F:%.*]] = sitofp i32 [[M]] to float
245+
; CHECK-NEXT: [[F:%.*]] = uitofp i32 [[M]] to float
246246
; CHECK-NEXT: [[R:%.*]] = fpext float [[F]] to double
247247
; CHECK-NEXT: ret double [[R]]
248248
;

0 commit comments

Comments
 (0)