Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0e501db

Browse files
yingopqtstellar
authored andcommitted
[Mips] Restore wrong deletion of instruction 'and' in unsigned min/max processing. (llvm#85902)
Fix llvm#61881 (cherry picked from commit 5d7fd6a)
1 parent fbb27d1 commit 0e501db

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

llvm/lib/Target/Mips/MipsExpandPseudo.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,15 @@ bool MipsExpandPseudo::expandAtomicBinOpSubword(
500500
.addReg(Incr, RegState::Kill)
501501
.addImm(ShiftImm);
502502
}
503+
} else {
504+
// and OldVal, OldVal, Mask
505+
// and Incr, Incr, Mask
506+
BuildMI(loopMBB, DL, TII->get(Mips::AND), OldVal)
507+
.addReg(OldVal)
508+
.addReg(Mask);
509+
BuildMI(loopMBB, DL, TII->get(Mips::AND), Incr)
510+
.addReg(Incr)
511+
.addReg(Mask);
503512
}
504513
}
505514
// unsigned: sltu Scratch4, oldVal, Incr

llvm/test/CodeGen/Mips/atomic-min-max.ll

+56
Original file line numberDiff line numberDiff line change
@@ -2146,6 +2146,8 @@ define i16 @test_umax_16(ptr nocapture %ptr, i16 signext %val) {
21462146
; MIPS32-NEXT: $BB6_1: # %entry
21472147
; MIPS32-NEXT: # =>This Inner Loop Header: Depth=1
21482148
; MIPS32-NEXT: ll $2, 0($6)
2149+
; MIPS32-NEXT: and $2, $2, $8
2150+
; MIPS32-NEXT: and $7, $7, $8
21492151
; MIPS32-NEXT: sltu $5, $2, $7
21502152
; MIPS32-NEXT: move $3, $2
21512153
; MIPS32-NEXT: movn $3, $7, $5
@@ -2186,6 +2188,8 @@ define i16 @test_umax_16(ptr nocapture %ptr, i16 signext %val) {
21862188
; MIPSEL-NEXT: $BB6_1: # %entry
21872189
; MIPSEL-NEXT: # =>This Inner Loop Header: Depth=1
21882190
; MIPSEL-NEXT: ll $2, 0($6)
2191+
; MIPSEL-NEXT: and $2, $2, $8
2192+
; MIPSEL-NEXT: and $7, $7, $8
21892193
; MIPSEL-NEXT: sltu $5, $2, $7
21902194
; MIPSEL-NEXT: move $3, $2
21912195
; MIPSEL-NEXT: movn $3, $7, $5
@@ -2225,6 +2229,8 @@ define i16 @test_umax_16(ptr nocapture %ptr, i16 signext %val) {
22252229
; MIPSELR6-NEXT: $BB6_1: # %entry
22262230
; MIPSELR6-NEXT: # =>This Inner Loop Header: Depth=1
22272231
; MIPSELR6-NEXT: ll $2, 0($6)
2232+
; MIPSELR6-NEXT: and $2, $2, $8
2233+
; MIPSELR6-NEXT: and $7, $7, $8
22282234
; MIPSELR6-NEXT: sltu $5, $2, $7
22292235
; MIPSELR6-NEXT: seleqz $3, $2, $5
22302236
; MIPSELR6-NEXT: selnez $5, $7, $5
@@ -2263,6 +2269,8 @@ define i16 @test_umax_16(ptr nocapture %ptr, i16 signext %val) {
22632269
; MMEL-NEXT: $BB6_1: # %entry
22642270
; MMEL-NEXT: # =>This Inner Loop Header: Depth=1
22652271
; MMEL-NEXT: ll $2, 0($6)
2272+
; MMEL-NEXT: and $2, $2, $8
2273+
; MMEL-NEXT: and $7, $7, $8
22662274
; MMEL-NEXT: sltu $5, $2, $7
22672275
; MMEL-NEXT: or $3, $2, $zero
22682276
; MMEL-NEXT: movn $3, $7, $5
@@ -2300,6 +2308,8 @@ define i16 @test_umax_16(ptr nocapture %ptr, i16 signext %val) {
23002308
; MMELR6-NEXT: $BB6_1: # %entry
23012309
; MMELR6-NEXT: # =>This Inner Loop Header: Depth=1
23022310
; MMELR6-NEXT: ll $2, 0($6)
2311+
; MMELR6-NEXT: and $2, $2, $8
2312+
; MMELR6-NEXT: and $7, $7, $8
23032313
; MMELR6-NEXT: sltu $5, $2, $7
23042314
; MMELR6-NEXT: seleqz $3, $2, $5
23052315
; MMELR6-NEXT: selnez $5, $7, $5
@@ -2417,6 +2427,8 @@ define i16 @test_umax_16(ptr nocapture %ptr, i16 signext %val) {
24172427
; MIPS64EL-NEXT: .LBB6_1: # %entry
24182428
; MIPS64EL-NEXT: # =>This Inner Loop Header: Depth=1
24192429
; MIPS64EL-NEXT: ll $2, 0($6)
2430+
; MIPS64EL-NEXT: and $2, $2, $8
2431+
; MIPS64EL-NEXT: and $7, $7, $8
24202432
; MIPS64EL-NEXT: sltu $5, $2, $7
24212433
; MIPS64EL-NEXT: move $3, $2
24222434
; MIPS64EL-NEXT: movn $3, $7, $5
@@ -2456,6 +2468,8 @@ define i16 @test_umax_16(ptr nocapture %ptr, i16 signext %val) {
24562468
; MIPS64ELR6-NEXT: .LBB6_1: # %entry
24572469
; MIPS64ELR6-NEXT: # =>This Inner Loop Header: Depth=1
24582470
; MIPS64ELR6-NEXT: ll $2, 0($6)
2471+
; MIPS64ELR6-NEXT: and $2, $2, $8
2472+
; MIPS64ELR6-NEXT: and $7, $7, $8
24592473
; MIPS64ELR6-NEXT: sltu $5, $2, $7
24602474
; MIPS64ELR6-NEXT: seleqz $3, $2, $5
24612475
; MIPS64ELR6-NEXT: selnez $5, $7, $5
@@ -2655,6 +2669,8 @@ define i16 @test_umin_16(ptr nocapture %ptr, i16 signext %val) {
26552669
; MIPS32-NEXT: $BB7_1: # %entry
26562670
; MIPS32-NEXT: # =>This Inner Loop Header: Depth=1
26572671
; MIPS32-NEXT: ll $2, 0($6)
2672+
; MIPS32-NEXT: and $2, $2, $8
2673+
; MIPS32-NEXT: and $7, $7, $8
26582674
; MIPS32-NEXT: sltu $5, $2, $7
26592675
; MIPS32-NEXT: move $3, $2
26602676
; MIPS32-NEXT: movz $3, $7, $5
@@ -2696,6 +2712,8 @@ define i16 @test_umin_16(ptr nocapture %ptr, i16 signext %val) {
26962712
; MIPSEL-NEXT: $BB7_1: # %entry
26972713
; MIPSEL-NEXT: # =>This Inner Loop Header: Depth=1
26982714
; MIPSEL-NEXT: ll $2, 0($6)
2715+
; MIPSEL-NEXT: and $2, $2, $8
2716+
; MIPSEL-NEXT: and $7, $7, $8
26992717
; MIPSEL-NEXT: sltu $5, $2, $7
27002718
; MIPSEL-NEXT: move $3, $2
27012719
; MIPSEL-NEXT: movz $3, $7, $5
@@ -2735,6 +2753,8 @@ define i16 @test_umin_16(ptr nocapture %ptr, i16 signext %val) {
27352753
; MIPSELR6-NEXT: $BB7_1: # %entry
27362754
; MIPSELR6-NEXT: # =>This Inner Loop Header: Depth=1
27372755
; MIPSELR6-NEXT: ll $2, 0($6)
2756+
; MIPSELR6-NEXT: and $2, $2, $8
2757+
; MIPSELR6-NEXT: and $7, $7, $8
27382758
; MIPSELR6-NEXT: sltu $5, $2, $7
27392759
; MIPSELR6-NEXT: selnez $3, $2, $5
27402760
; MIPSELR6-NEXT: seleqz $5, $7, $5
@@ -2773,6 +2793,8 @@ define i16 @test_umin_16(ptr nocapture %ptr, i16 signext %val) {
27732793
; MMEL-NEXT: $BB7_1: # %entry
27742794
; MMEL-NEXT: # =>This Inner Loop Header: Depth=1
27752795
; MMEL-NEXT: ll $2, 0($6)
2796+
; MMEL-NEXT: and $2, $2, $8
2797+
; MMEL-NEXT: and $7, $7, $8
27762798
; MMEL-NEXT: sltu $5, $2, $7
27772799
; MMEL-NEXT: or $3, $2, $zero
27782800
; MMEL-NEXT: movz $3, $7, $5
@@ -2810,6 +2832,8 @@ define i16 @test_umin_16(ptr nocapture %ptr, i16 signext %val) {
28102832
; MMELR6-NEXT: $BB7_1: # %entry
28112833
; MMELR6-NEXT: # =>This Inner Loop Header: Depth=1
28122834
; MMELR6-NEXT: ll $2, 0($6)
2835+
; MMELR6-NEXT: and $2, $2, $8
2836+
; MMELR6-NEXT: and $7, $7, $8
28132837
; MMELR6-NEXT: sltu $5, $2, $7
28142838
; MMELR6-NEXT: selnez $3, $2, $5
28152839
; MMELR6-NEXT: seleqz $5, $7, $5
@@ -2927,6 +2951,8 @@ define i16 @test_umin_16(ptr nocapture %ptr, i16 signext %val) {
29272951
; MIPS64EL-NEXT: .LBB7_1: # %entry
29282952
; MIPS64EL-NEXT: # =>This Inner Loop Header: Depth=1
29292953
; MIPS64EL-NEXT: ll $2, 0($6)
2954+
; MIPS64EL-NEXT: and $2, $2, $8
2955+
; MIPS64EL-NEXT: and $7, $7, $8
29302956
; MIPS64EL-NEXT: sltu $5, $2, $7
29312957
; MIPS64EL-NEXT: move $3, $2
29322958
; MIPS64EL-NEXT: movz $3, $7, $5
@@ -2966,6 +2992,8 @@ define i16 @test_umin_16(ptr nocapture %ptr, i16 signext %val) {
29662992
; MIPS64ELR6-NEXT: .LBB7_1: # %entry
29672993
; MIPS64ELR6-NEXT: # =>This Inner Loop Header: Depth=1
29682994
; MIPS64ELR6-NEXT: ll $2, 0($6)
2995+
; MIPS64ELR6-NEXT: and $2, $2, $8
2996+
; MIPS64ELR6-NEXT: and $7, $7, $8
29692997
; MIPS64ELR6-NEXT: sltu $5, $2, $7
29702998
; MIPS64ELR6-NEXT: selnez $3, $2, $5
29712999
; MIPS64ELR6-NEXT: seleqz $5, $7, $5
@@ -4244,6 +4272,8 @@ define i8 @test_umax_8(ptr nocapture %ptr, i8 signext %val) {
42444272
; MIPS32-NEXT: $BB10_1: # %entry
42454273
; MIPS32-NEXT: # =>This Inner Loop Header: Depth=1
42464274
; MIPS32-NEXT: ll $2, 0($6)
4275+
; MIPS32-NEXT: and $2, $2, $8
4276+
; MIPS32-NEXT: and $7, $7, $8
42474277
; MIPS32-NEXT: sltu $5, $2, $7
42484278
; MIPS32-NEXT: move $3, $2
42494279
; MIPS32-NEXT: movn $3, $7, $5
@@ -4284,6 +4314,8 @@ define i8 @test_umax_8(ptr nocapture %ptr, i8 signext %val) {
42844314
; MIPSEL-NEXT: $BB10_1: # %entry
42854315
; MIPSEL-NEXT: # =>This Inner Loop Header: Depth=1
42864316
; MIPSEL-NEXT: ll $2, 0($6)
4317+
; MIPSEL-NEXT: and $2, $2, $8
4318+
; MIPSEL-NEXT: and $7, $7, $8
42874319
; MIPSEL-NEXT: sltu $5, $2, $7
42884320
; MIPSEL-NEXT: move $3, $2
42894321
; MIPSEL-NEXT: movn $3, $7, $5
@@ -4323,6 +4355,8 @@ define i8 @test_umax_8(ptr nocapture %ptr, i8 signext %val) {
43234355
; MIPSELR6-NEXT: $BB10_1: # %entry
43244356
; MIPSELR6-NEXT: # =>This Inner Loop Header: Depth=1
43254357
; MIPSELR6-NEXT: ll $2, 0($6)
4358+
; MIPSELR6-NEXT: and $2, $2, $8
4359+
; MIPSELR6-NEXT: and $7, $7, $8
43264360
; MIPSELR6-NEXT: sltu $5, $2, $7
43274361
; MIPSELR6-NEXT: seleqz $3, $2, $5
43284362
; MIPSELR6-NEXT: selnez $5, $7, $5
@@ -4361,6 +4395,8 @@ define i8 @test_umax_8(ptr nocapture %ptr, i8 signext %val) {
43614395
; MMEL-NEXT: $BB10_1: # %entry
43624396
; MMEL-NEXT: # =>This Inner Loop Header: Depth=1
43634397
; MMEL-NEXT: ll $2, 0($6)
4398+
; MMEL-NEXT: and $2, $2, $8
4399+
; MMEL-NEXT: and $7, $7, $8
43644400
; MMEL-NEXT: sltu $5, $2, $7
43654401
; MMEL-NEXT: or $3, $2, $zero
43664402
; MMEL-NEXT: movn $3, $7, $5
@@ -4398,6 +4434,8 @@ define i8 @test_umax_8(ptr nocapture %ptr, i8 signext %val) {
43984434
; MMELR6-NEXT: $BB10_1: # %entry
43994435
; MMELR6-NEXT: # =>This Inner Loop Header: Depth=1
44004436
; MMELR6-NEXT: ll $2, 0($6)
4437+
; MMELR6-NEXT: and $2, $2, $8
4438+
; MMELR6-NEXT: and $7, $7, $8
44014439
; MMELR6-NEXT: sltu $5, $2, $7
44024440
; MMELR6-NEXT: seleqz $3, $2, $5
44034441
; MMELR6-NEXT: selnez $5, $7, $5
@@ -4515,6 +4553,8 @@ define i8 @test_umax_8(ptr nocapture %ptr, i8 signext %val) {
45154553
; MIPS64EL-NEXT: .LBB10_1: # %entry
45164554
; MIPS64EL-NEXT: # =>This Inner Loop Header: Depth=1
45174555
; MIPS64EL-NEXT: ll $2, 0($6)
4556+
; MIPS64EL-NEXT: and $2, $2, $8
4557+
; MIPS64EL-NEXT: and $7, $7, $8
45184558
; MIPS64EL-NEXT: sltu $5, $2, $7
45194559
; MIPS64EL-NEXT: move $3, $2
45204560
; MIPS64EL-NEXT: movn $3, $7, $5
@@ -4554,6 +4594,8 @@ define i8 @test_umax_8(ptr nocapture %ptr, i8 signext %val) {
45544594
; MIPS64ELR6-NEXT: .LBB10_1: # %entry
45554595
; MIPS64ELR6-NEXT: # =>This Inner Loop Header: Depth=1
45564596
; MIPS64ELR6-NEXT: ll $2, 0($6)
4597+
; MIPS64ELR6-NEXT: and $2, $2, $8
4598+
; MIPS64ELR6-NEXT: and $7, $7, $8
45574599
; MIPS64ELR6-NEXT: sltu $5, $2, $7
45584600
; MIPS64ELR6-NEXT: seleqz $3, $2, $5
45594601
; MIPS64ELR6-NEXT: selnez $5, $7, $5
@@ -4753,6 +4795,8 @@ define i8 @test_umin_8(ptr nocapture %ptr, i8 signext %val) {
47534795
; MIPS32-NEXT: $BB11_1: # %entry
47544796
; MIPS32-NEXT: # =>This Inner Loop Header: Depth=1
47554797
; MIPS32-NEXT: ll $2, 0($6)
4798+
; MIPS32-NEXT: and $2, $2, $8
4799+
; MIPS32-NEXT: and $7, $7, $8
47564800
; MIPS32-NEXT: sltu $5, $2, $7
47574801
; MIPS32-NEXT: move $3, $2
47584802
; MIPS32-NEXT: movz $3, $7, $5
@@ -4793,6 +4837,8 @@ define i8 @test_umin_8(ptr nocapture %ptr, i8 signext %val) {
47934837
; MIPSEL-NEXT: $BB11_1: # %entry
47944838
; MIPSEL-NEXT: # =>This Inner Loop Header: Depth=1
47954839
; MIPSEL-NEXT: ll $2, 0($6)
4840+
; MIPSEL-NEXT: and $2, $2, $8
4841+
; MIPSEL-NEXT: and $7, $7, $8
47964842
; MIPSEL-NEXT: sltu $5, $2, $7
47974843
; MIPSEL-NEXT: move $3, $2
47984844
; MIPSEL-NEXT: movz $3, $7, $5
@@ -4832,6 +4878,8 @@ define i8 @test_umin_8(ptr nocapture %ptr, i8 signext %val) {
48324878
; MIPSELR6-NEXT: $BB11_1: # %entry
48334879
; MIPSELR6-NEXT: # =>This Inner Loop Header: Depth=1
48344880
; MIPSELR6-NEXT: ll $2, 0($6)
4881+
; MIPSELR6-NEXT: and $2, $2, $8
4882+
; MIPSELR6-NEXT: and $7, $7, $8
48354883
; MIPSELR6-NEXT: sltu $5, $2, $7
48364884
; MIPSELR6-NEXT: selnez $3, $2, $5
48374885
; MIPSELR6-NEXT: seleqz $5, $7, $5
@@ -4870,6 +4918,8 @@ define i8 @test_umin_8(ptr nocapture %ptr, i8 signext %val) {
48704918
; MMEL-NEXT: $BB11_1: # %entry
48714919
; MMEL-NEXT: # =>This Inner Loop Header: Depth=1
48724920
; MMEL-NEXT: ll $2, 0($6)
4921+
; MMEL-NEXT: and $2, $2, $8
4922+
; MMEL-NEXT: and $7, $7, $8
48734923
; MMEL-NEXT: sltu $5, $2, $7
48744924
; MMEL-NEXT: or $3, $2, $zero
48754925
; MMEL-NEXT: movz $3, $7, $5
@@ -4907,6 +4957,8 @@ define i8 @test_umin_8(ptr nocapture %ptr, i8 signext %val) {
49074957
; MMELR6-NEXT: $BB11_1: # %entry
49084958
; MMELR6-NEXT: # =>This Inner Loop Header: Depth=1
49094959
; MMELR6-NEXT: ll $2, 0($6)
4960+
; MMELR6-NEXT: and $2, $2, $8
4961+
; MMELR6-NEXT: and $7, $7, $8
49104962
; MMELR6-NEXT: sltu $5, $2, $7
49114963
; MMELR6-NEXT: selnez $3, $2, $5
49124964
; MMELR6-NEXT: seleqz $5, $7, $5
@@ -5024,6 +5076,8 @@ define i8 @test_umin_8(ptr nocapture %ptr, i8 signext %val) {
50245076
; MIPS64EL-NEXT: .LBB11_1: # %entry
50255077
; MIPS64EL-NEXT: # =>This Inner Loop Header: Depth=1
50265078
; MIPS64EL-NEXT: ll $2, 0($6)
5079+
; MIPS64EL-NEXT: and $2, $2, $8
5080+
; MIPS64EL-NEXT: and $7, $7, $8
50275081
; MIPS64EL-NEXT: sltu $5, $2, $7
50285082
; MIPS64EL-NEXT: move $3, $2
50295083
; MIPS64EL-NEXT: movz $3, $7, $5
@@ -5063,6 +5117,8 @@ define i8 @test_umin_8(ptr nocapture %ptr, i8 signext %val) {
50635117
; MIPS64ELR6-NEXT: .LBB11_1: # %entry
50645118
; MIPS64ELR6-NEXT: # =>This Inner Loop Header: Depth=1
50655119
; MIPS64ELR6-NEXT: ll $2, 0($6)
5120+
; MIPS64ELR6-NEXT: and $2, $2, $8
5121+
; MIPS64ELR6-NEXT: and $7, $7, $8
50665122
; MIPS64ELR6-NEXT: sltu $5, $2, $7
50675123
; MIPS64ELR6-NEXT: selnez $3, $2, $5
50685124
; MIPS64ELR6-NEXT: seleqz $5, $7, $5

0 commit comments

Comments
 (0)