Skip to content

Commit cb0ccc6

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 b4001e3 commit cb0ccc6

File tree

10 files changed

+71
-67
lines changed

10 files changed

+71
-67
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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
;
@@ -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
;
@@ -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: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ define half @test_si_si_i8_sub(i8 noundef %x_in, i8 noundef %y_in) {
166166
; CHECK-NEXT: [[X:%.*]] = and i8 [[X_IN:%.*]], 63
167167
; CHECK-NEXT: [[Y:%.*]] = or i8 [[Y_IN:%.*]], -64
168168
; CHECK-NEXT: [[TMP1:%.*]] = sub nsw i8 [[X]], [[Y]]
169-
; CHECK-NEXT: [[R:%.*]] = sitofp i8 [[TMP1]] to half
169+
; CHECK-NEXT: [[R:%.*]] = uitofp i8 [[TMP1]] to half
170170
; CHECK-NEXT: ret half [[R]]
171171
;
172172
%x = and i8 %x_in, 63
@@ -181,7 +181,7 @@ define half @test_si_si_i8_sub_fail_overflow(i8 noundef %x_in, i8 noundef %y_in)
181181
; CHECK-LABEL: @test_si_si_i8_sub_fail_overflow(
182182
; CHECK-NEXT: [[X:%.*]] = and i8 [[X_IN:%.*]], 63
183183
; CHECK-NEXT: [[Y:%.*]] = or i8 [[Y_IN:%.*]], -65
184-
; CHECK-NEXT: [[XF:%.*]] = sitofp i8 [[X]] to half
184+
; CHECK-NEXT: [[XF:%.*]] = uitofp i8 [[X]] to half
185185
; CHECK-NEXT: [[YF:%.*]] = sitofp i8 [[Y]] to half
186186
; CHECK-NEXT: [[R:%.*]] = fsub half [[XF]], [[YF]]
187187
; CHECK-NEXT: ret half [[R]]
@@ -198,7 +198,7 @@ define half @test_si_si_i8_sub_C(i8 noundef %x_in) {
198198
; CHECK-LABEL: @test_si_si_i8_sub_C(
199199
; CHECK-NEXT: [[X:%.*]] = and i8 [[X_IN:%.*]], 63
200200
; CHECK-NEXT: [[TMP1:%.*]] = or disjoint i8 [[X]], 64
201-
; CHECK-NEXT: [[R:%.*]] = sitofp i8 [[TMP1]] to half
201+
; CHECK-NEXT: [[R:%.*]] = uitofp i8 [[TMP1]] to half
202202
; CHECK-NEXT: ret half [[R]]
203203
;
204204
%x = and i8 %x_in, 63
@@ -315,7 +315,7 @@ define half @test_si_si_i8_mul_fail_maybe_zero(i8 noundef %x_in, i8 noundef %y_i
315315
; CHECK-LABEL: @test_si_si_i8_mul_fail_maybe_zero(
316316
; CHECK-NEXT: [[X:%.*]] = and i8 [[X_IN:%.*]], 7
317317
; CHECK-NEXT: [[Y:%.*]] = or i8 [[Y_IN:%.*]], -8
318-
; CHECK-NEXT: [[XF:%.*]] = sitofp i8 [[X]] to half
318+
; CHECK-NEXT: [[XF:%.*]] = uitofp i8 [[X]] to half
319319
; CHECK-NEXT: [[YF:%.*]] = sitofp i8 [[Y]] to half
320320
; CHECK-NEXT: [[R:%.*]] = fmul half [[XF]], [[YF]]
321321
; CHECK-NEXT: ret half [[R]]
@@ -332,7 +332,7 @@ define half @test_si_si_i8_mul_C_fail_no_repr(i8 noundef %x_in) {
332332
; CHECK-LABEL: @test_si_si_i8_mul_C_fail_no_repr(
333333
; CHECK-NEXT: [[XX:%.*]] = and i8 [[X_IN:%.*]], 6
334334
; CHECK-NEXT: [[X:%.*]] = or disjoint i8 [[XX]], 1
335-
; CHECK-NEXT: [[XF:%.*]] = sitofp i8 [[X]] to half
335+
; CHECK-NEXT: [[XF:%.*]] = uitofp i8 [[X]] to half
336336
; CHECK-NEXT: [[R:%.*]] = fmul half [[XF]], 0xHC780
337337
; CHECK-NEXT: ret half [[R]]
338338
;
@@ -347,7 +347,7 @@ define half @test_si_si_i8_mul_C_fail_overflow(i8 noundef %x_in) {
347347
; CHECK-LABEL: @test_si_si_i8_mul_C_fail_overflow(
348348
; CHECK-NEXT: [[XX:%.*]] = and i8 [[X_IN:%.*]], 6
349349
; CHECK-NEXT: [[X:%.*]] = or disjoint i8 [[XX]], 1
350-
; CHECK-NEXT: [[XF:%.*]] = sitofp i8 [[X]] to half
350+
; CHECK-NEXT: [[XF:%.*]] = uitofp i8 [[X]] to half
351351
; CHECK-NEXT: [[R:%.*]] = fmul half [[XF]], 0xHCCC0
352352
; CHECK-NEXT: ret half [[R]]
353353
;
@@ -401,7 +401,7 @@ define half @test_ui_si_i8_mul_fail_signed(i8 noundef %x_in, i8 noundef %y_in) {
401401
; CHECK-NEXT: [[XX:%.*]] = and i8 [[X_IN:%.*]], 7
402402
; CHECK-NEXT: [[X:%.*]] = add nuw nsw i8 [[XX]], 1
403403
; CHECK-NEXT: [[Y:%.*]] = or i8 [[Y_IN:%.*]], -4
404-
; CHECK-NEXT: [[XF:%.*]] = sitofp i8 [[X]] to half
404+
; CHECK-NEXT: [[XF:%.*]] = uitofp i8 [[X]] to half
405405
; CHECK-NEXT: [[YF:%.*]] = uitofp i8 [[Y]] to half
406406
; CHECK-NEXT: [[R:%.*]] = fmul half [[XF]], [[YF]]
407407
; CHECK-NEXT: ret half [[R]]
@@ -541,7 +541,7 @@ define half @test_si_si_i16_sub_fail_no_promotion(i16 noundef %x_in, i16 noundef
541541
; CHECK-LABEL: @test_si_si_i16_sub_fail_no_promotion(
542542
; CHECK-NEXT: [[X:%.*]] = and i16 [[X_IN:%.*]], 2047
543543
; CHECK-NEXT: [[Y:%.*]] = or i16 [[Y_IN:%.*]], -2049
544-
; CHECK-NEXT: [[XF:%.*]] = sitofp i16 [[X]] to half
544+
; CHECK-NEXT: [[XF:%.*]] = uitofp i16 [[X]] to half
545545
; CHECK-NEXT: [[YF:%.*]] = sitofp i16 [[Y]] to half
546546
; CHECK-NEXT: [[R:%.*]] = fsub half [[XF]], [[YF]]
547547
; CHECK-NEXT: ret half [[R]]
@@ -575,7 +575,7 @@ define half @test_ui_si_i16_sub_fail_maybe_signed(i16 noundef %x_in, i16 noundef
575575
; CHECK-NEXT: [[X:%.*]] = or i16 [[X_IN:%.*]], -2048
576576
; CHECK-NEXT: [[Y:%.*]] = and i16 [[Y_IN:%.*]], 2047
577577
; CHECK-NEXT: [[XF:%.*]] = uitofp i16 [[X]] to half
578-
; CHECK-NEXT: [[YF:%.*]] = sitofp i16 [[Y]] to half
578+
; CHECK-NEXT: [[YF:%.*]] = uitofp i16 [[Y]] to half
579579
; CHECK-NEXT: [[R:%.*]] = fsub half [[XF]], [[YF]]
580580
; CHECK-NEXT: ret half [[R]]
581581
;
@@ -643,7 +643,7 @@ define half @test_si_si_i16_mul_fail_overflow(i16 noundef %x_in, i16 noundef %y_
643643
; CHECK-NEXT: [[XX:%.*]] = and i16 [[X_IN:%.*]], 126
644644
; CHECK-NEXT: [[X:%.*]] = or disjoint i16 [[XX]], 1
645645
; CHECK-NEXT: [[Y:%.*]] = or i16 [[Y_IN:%.*]], -257
646-
; CHECK-NEXT: [[XF:%.*]] = sitofp i16 [[X]] to half
646+
; CHECK-NEXT: [[XF:%.*]] = uitofp i16 [[X]] to half
647647
; CHECK-NEXT: [[YF:%.*]] = sitofp i16 [[Y]] to half
648648
; CHECK-NEXT: [[R:%.*]] = fmul half [[XF]], [[YF]]
649649
; CHECK-NEXT: ret half [[R]]
@@ -821,7 +821,7 @@ define half @test_si_si_i12_sub(i12 noundef %x_in, i12 noundef %y_in) {
821821
; CHECK-NEXT: [[X:%.*]] = and i12 [[X_IN:%.*]], 1023
822822
; CHECK-NEXT: [[Y:%.*]] = or i12 [[Y_IN:%.*]], -1024
823823
; CHECK-NEXT: [[TMP1:%.*]] = sub nsw i12 [[X]], [[Y]]
824-
; CHECK-NEXT: [[R:%.*]] = sitofp i12 [[TMP1]] to half
824+
; CHECK-NEXT: [[R:%.*]] = uitofp i12 [[TMP1]] to half
825825
; CHECK-NEXT: ret half [[R]]
826826
;
827827
%x = and i12 %x_in, 1023
@@ -915,7 +915,7 @@ define half @test_si_si_i12_mul_fail_overflow(i12 noundef %x_in, i12 noundef %y_
915915
; CHECK-NEXT: [[XX:%.*]] = and i12 [[X_IN:%.*]], 30
916916
; CHECK-NEXT: [[X:%.*]] = or disjoint i12 [[XX]], 1
917917
; CHECK-NEXT: [[Y:%.*]] = or i12 [[Y_IN:%.*]], -128
918-
; CHECK-NEXT: [[XF:%.*]] = sitofp i12 [[X]] to half
918+
; CHECK-NEXT: [[XF:%.*]] = uitofp i12 [[X]] to half
919919
; CHECK-NEXT: [[YF:%.*]] = sitofp i12 [[Y]] to half
920920
; CHECK-NEXT: [[R:%.*]] = fmul half [[XF]], [[YF]]
921921
; CHECK-NEXT: ret half [[R]]
@@ -933,7 +933,7 @@ define half @test_si_si_i12_mul_fail_maybe_non_zero(i12 noundef %x_in, i12 nound
933933
; CHECK-LABEL: @test_si_si_i12_mul_fail_maybe_non_zero(
934934
; CHECK-NEXT: [[X:%.*]] = and i12 [[X_IN:%.*]], 30
935935
; CHECK-NEXT: [[Y:%.*]] = or i12 [[Y_IN:%.*]], -128
936-
; CHECK-NEXT: [[XF:%.*]] = sitofp i12 [[X]] to half
936+
; CHECK-NEXT: [[XF:%.*]] = uitofp i12 [[X]] to half
937937
; CHECK-NEXT: [[YF:%.*]] = sitofp i12 [[Y]] to half
938938
; CHECK-NEXT: [[R:%.*]] = fmul half [[XF]], [[YF]]
939939
; CHECK-NEXT: ret half [[R]]
@@ -950,7 +950,7 @@ define half @test_si_si_i12_mul_C(i12 noundef %x_in) {
950950
; CHECK-LABEL: @test_si_si_i12_mul_C(
951951
; CHECK-NEXT: [[X:%.*]] = or i12 [[X_IN:%.*]], -64
952952
; CHECK-NEXT: [[TMP1:%.*]] = mul nsw i12 [[X]], -16
953-
; CHECK-NEXT: [[R:%.*]] = sitofp i12 [[TMP1]] to half
953+
; CHECK-NEXT: [[R:%.*]] = uitofp i12 [[TMP1]] to half
954954
; CHECK-NEXT: ret half [[R]]
955955
;
956956
%x = or i12 %x_in, -64

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
;

llvm/test/Transforms/InstCombine/minmax-fold.ll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ define i64 @t9(i32 %a) {
131131
define float @t10(i32 %x) {
132132
; CHECK-LABEL: @t10(
133133
; CHECK-NEXT: [[R1:%.*]] = call i32 @llvm.smax.i32(i32 [[X:%.*]], i32 255)
134-
; CHECK-NEXT: [[R:%.*]] = sitofp i32 [[R1]] to float
134+
; CHECK-NEXT: [[R:%.*]] = uitofp i32 [[R1]] to float
135135
; CHECK-NEXT: ret float [[R]]
136136
;
137137
%f_x = sitofp i32 %x to float
@@ -143,7 +143,7 @@ define float @t10(i32 %x) {
143143
define float @t11(i64 %x) {
144144
; CHECK-LABEL: @t11(
145145
; CHECK-NEXT: [[R1:%.*]] = call i64 @llvm.smax.i64(i64 [[X:%.*]], i64 255)
146-
; CHECK-NEXT: [[R:%.*]] = sitofp i64 [[R1]] to float
146+
; CHECK-NEXT: [[R:%.*]] = uitofp i64 [[R1]] to float
147147
; CHECK-NEXT: ret float [[R]]
148148
;
149149
%f_x = sitofp i64 %x to float
@@ -526,7 +526,7 @@ falselabel:
526526
define double @PR31751_umin1(i32 %x) {
527527
; CHECK-LABEL: @PR31751_umin1(
528528
; CHECK-NEXT: [[SEL:%.*]] = call i32 @llvm.umin.i32(i32 [[X:%.*]], i32 2147483647)
529-
; CHECK-NEXT: [[CONV:%.*]] = sitofp i32 [[SEL]] to double
529+
; CHECK-NEXT: [[CONV:%.*]] = uitofp i32 [[SEL]] to double
530530
; CHECK-NEXT: ret double [[CONV]]
531531
;
532532
%cmp = icmp slt i32 %x, 0
@@ -538,7 +538,7 @@ define double @PR31751_umin1(i32 %x) {
538538
define double @PR31751_umin2(i32 %x) {
539539
; CHECK-LABEL: @PR31751_umin2(
540540
; CHECK-NEXT: [[SEL:%.*]] = call i32 @llvm.umin.i32(i32 [[X:%.*]], i32 2147483647)
541-
; CHECK-NEXT: [[CONV:%.*]] = sitofp i32 [[SEL]] to double
541+
; CHECK-NEXT: [[CONV:%.*]] = uitofp i32 [[SEL]] to double
542542
; CHECK-NEXT: ret double [[CONV]]
543543
;
544544
%cmp = icmp ult i32 %x, 2147483647
@@ -550,7 +550,7 @@ define double @PR31751_umin2(i32 %x) {
550550
define double @PR31751_umin3(i32 %x) {
551551
; CHECK-LABEL: @PR31751_umin3(
552552
; CHECK-NEXT: [[SEL:%.*]] = call i32 @llvm.umin.i32(i32 [[X:%.*]], i32 2147483647)
553-
; CHECK-NEXT: [[CONV:%.*]] = sitofp i32 [[SEL]] to double
553+
; CHECK-NEXT: [[CONV:%.*]] = uitofp i32 [[SEL]] to double
554554
; CHECK-NEXT: ret double [[CONV]]
555555
;
556556
%cmp = icmp ugt i32 %x, 2147483647

llvm/test/Transforms/InstCombine/minmax-fp.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ define double @t16(i32 %x) {
257257
define double @t17(i32 %x) {
258258
; CHECK-LABEL: @t17(
259259
; CHECK-NEXT: [[SEL1:%.*]] = call i32 @llvm.smax.i32(i32 [[X:%.*]], i32 2)
260-
; CHECK-NEXT: [[SEL:%.*]] = sitofp i32 [[SEL1]] to double
260+
; CHECK-NEXT: [[SEL:%.*]] = uitofp i32 [[SEL1]] to double
261261
; CHECK-NEXT: ret double [[SEL]]
262262
;
263263
%cmp = icmp sgt i32 %x, 2

llvm/test/Transforms/InstCombine/pr27236.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
define float @test1(i32 %scale) {
55
; CHECK-LABEL: @test1(
66
; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.smax.i32(i32 [[SCALE:%.*]], i32 1)
7-
; CHECK-NEXT: [[TMP2:%.*]] = sitofp i32 [[TMP1]] to float
7+
; CHECK-NEXT: [[TMP2:%.*]] = uitofp i32 [[TMP1]] to float
88
; CHECK-NEXT: ret float [[TMP2]]
99
;
1010
%1 = icmp sgt i32 1, %scale

llvm/test/Transforms/LoopVectorize/X86/float-induction-x86.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ define void @fp_iv_loop1(ptr noalias nocapture %A, i32 %N) #0 {
2525
; AUTO_VEC-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[FOR_BODY:%.*]], label [[VECTOR_PH:%.*]]
2626
; AUTO_VEC: vector.ph:
2727
; AUTO_VEC-NEXT: [[N_VEC:%.*]] = and i64 [[ZEXT]], 2147483616
28-
; AUTO_VEC-NEXT: [[DOTCAST:%.*]] = sitofp i64 [[N_VEC]] to float
28+
; AUTO_VEC-NEXT: [[DOTCAST:%.*]] = uitofp i64 [[N_VEC]] to float
2929
; AUTO_VEC-NEXT: [[TMP0:%.*]] = fmul fast float [[DOTCAST]], 5.000000e-01
3030
; AUTO_VEC-NEXT: [[IND_END:%.*]] = fadd fast float [[TMP0]], 1.000000e+00
3131
; AUTO_VEC-NEXT: br label [[VECTOR_BODY:%.*]]
@@ -201,7 +201,7 @@ define double @external_use_with_fast_math(ptr %a, i64 %n) {
201201
; AUTO_VEC-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[FOR_BODY:%.*]], label [[VECTOR_PH:%.*]]
202202
; AUTO_VEC: vector.ph:
203203
; AUTO_VEC-NEXT: [[N_VEC:%.*]] = and i64 [[SMAX]], 9223372036854775792
204-
; AUTO_VEC-NEXT: [[DOTCAST:%.*]] = sitofp i64 [[N_VEC]] to double
204+
; AUTO_VEC-NEXT: [[DOTCAST:%.*]] = uitofp i64 [[N_VEC]] to double
205205
; AUTO_VEC-NEXT: [[TMP0:%.*]] = fmul fast double [[DOTCAST]], 3.000000e+00
206206
; AUTO_VEC-NEXT: br label [[VECTOR_BODY:%.*]]
207207
; AUTO_VEC: vector.body:
@@ -366,7 +366,7 @@ define void @fadd_reassoc_FMF(ptr nocapture %p, i32 %N) {
366366
; AUTO_VEC-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[FOR_BODY:%.*]], label [[VECTOR_PH:%.*]]
367367
; AUTO_VEC: vector.ph:
368368
; AUTO_VEC-NEXT: [[N_VEC:%.*]] = and i64 [[TMP0]], 4294967264
369-
; AUTO_VEC-NEXT: [[DOTCAST:%.*]] = sitofp i64 [[N_VEC]] to float
369+
; AUTO_VEC-NEXT: [[DOTCAST:%.*]] = uitofp i64 [[N_VEC]] to float
370370
; AUTO_VEC-NEXT: [[TMP1:%.*]] = fmul reassoc float [[DOTCAST]], 4.200000e+01
371371
; AUTO_VEC-NEXT: [[IND_END:%.*]] = fadd reassoc float [[TMP1]], 1.000000e+00
372372
; AUTO_VEC-NEXT: br label [[VECTOR_BODY:%.*]]

0 commit comments

Comments
 (0)