Skip to content

Commit 75ad0e0

Browse files
committed
[GISel] Funnel shift combiner port from SelectionDAG ISel to GlobalISel
The funnel shift combiner rule from 4a3708c is currently missing from GlobalISel. The following is a port of that combiner to GlobalISel.
1 parent cae0bf4 commit 75ad0e0

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

llvm/test/CodeGen/AArch64/funnel-shift.ll

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -674,14 +674,12 @@ define i32 @or_shl_fshl_simplify(i32 %x, i32 %y, i32 %s) {
674674
; CHECK-GI-LABEL: or_shl_fshl_simplify:
675675
; CHECK-GI: // %bb.0:
676676
; CHECK-GI-NEXT: mov w8, #31 // =0x1f
677-
; CHECK-GI-NEXT: and w9, w2, #0x1f
678-
; CHECK-GI-NEXT: lsr w10, w0, #1
679-
; CHECK-GI-NEXT: lsl w11, w1, w2
677+
; CHECK-GI-NEXT: lsr w9, w0, #1
678+
; CHECK-GI-NEXT: and w10, w2, #0x1f
680679
; CHECK-GI-NEXT: bic w8, w8, w2
681-
; CHECK-GI-NEXT: lsl w9, w1, w9
682-
; CHECK-GI-NEXT: lsr w8, w10, w8
683-
; CHECK-GI-NEXT: orr w9, w9, w11
684-
; CHECK-GI-NEXT: orr w0, w9, w8
680+
; CHECK-GI-NEXT: lsl w10, w1, w10
681+
; CHECK-GI-NEXT: lsr w8, w9, w8
682+
; CHECK-GI-NEXT: orr w0, w10, w8
685683
; CHECK-GI-NEXT: ret
686684
%shy = shl i32 %y, %s
687685
%fun = call i32 @llvm.fshl.i32(i32 %y, i32 %x, i32 %s)
@@ -702,14 +700,12 @@ define i32 @or_lshr_fshr_simplify(i32 %x, i32 %y, i32 %s) {
702700
; CHECK-GI-LABEL: or_lshr_fshr_simplify:
703701
; CHECK-GI: // %bb.0:
704702
; CHECK-GI-NEXT: mov w8, #31 // =0x1f
705-
; CHECK-GI-NEXT: and w9, w2, #0x1f
706-
; CHECK-GI-NEXT: lsl w10, w0, #1
707-
; CHECK-GI-NEXT: lsr w11, w1, w2
703+
; CHECK-GI-NEXT: lsl w9, w0, #1
704+
; CHECK-GI-NEXT: and w10, w2, #0x1f
708705
; CHECK-GI-NEXT: bic w8, w8, w2
709-
; CHECK-GI-NEXT: lsr w9, w1, w9
710-
; CHECK-GI-NEXT: lsl w8, w10, w8
711-
; CHECK-GI-NEXT: orr w9, w11, w9
712-
; CHECK-GI-NEXT: orr w0, w9, w8
706+
; CHECK-GI-NEXT: lsl w8, w9, w8
707+
; CHECK-GI-NEXT: lsr w9, w1, w10
708+
; CHECK-GI-NEXT: orr w0, w8, w9
713709
; CHECK-GI-NEXT: ret
714710
%shy = lshr i32 %y, %s
715711
%fun = call i32 @llvm.fshr.i32(i32 %x, i32 %y, i32 %s)

llvm/test/CodeGen/RISCV/GlobalISel/shift.ll

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ define i32 @test_fshl_i32(i32 %x, i32 %_, i32 %y) {
113113
; RV32-NEXT: sll a0, a0, a2
114114
; RV32-NEXT: srli a1, a1, 1
115115
; RV32-NEXT: srl a1, a1, a3
116-
; RV32-NEXT: or a0, a0, a0
117116
; RV32-NEXT: or a0, a0, a1
118117
; RV32-NEXT: ret
119118
;
@@ -123,7 +122,6 @@ define i32 @test_fshl_i32(i32 %x, i32 %_, i32 %y) {
123122
; RV64-NEXT: sllw a0, a0, a2
124123
; RV64-NEXT: srliw a1, a1, 1
125124
; RV64-NEXT: srlw a1, a1, a3
126-
; RV64-NEXT: or a0, a0, a0
127125
; RV64-NEXT: or a0, a0, a1
128126
; RV64-NEXT: ret
129127
%fshl = call i32 @llvm.fshl.i32(i32 %x, i32 %_, i32 %y)
@@ -137,20 +135,18 @@ define i32 @test_fshr_i32(i32 %_, i32 %x, i32 %y) {
137135
; RV32: # %bb.0:
138136
; RV32-NEXT: not a3, a2
139137
; RV32-NEXT: slli a0, a0, 1
140-
; RV32-NEXT: srl a1, a1, a2
141138
; RV32-NEXT: sll a0, a0, a3
142-
; RV32-NEXT: or a1, a1, a1
143-
; RV32-NEXT: or a0, a1, a0
139+
; RV32-NEXT: srl a1, a1, a2
140+
; RV32-NEXT: or a0, a0, a1
144141
; RV32-NEXT: ret
145142
;
146143
; RV64-LABEL: test_fshr_i32:
147144
; RV64: # %bb.0:
148145
; RV64-NEXT: not a3, a2
149146
; RV64-NEXT: slli a0, a0, 1
150-
; RV64-NEXT: srlw a1, a1, a2
151147
; RV64-NEXT: sllw a0, a0, a3
152-
; RV64-NEXT: or a1, a1, a1
153-
; RV64-NEXT: or a0, a1, a0
148+
; RV64-NEXT: srlw a1, a1, a2
149+
; RV64-NEXT: or a0, a0, a1
154150
; RV64-NEXT: ret
155151
%fshr = call i32 @llvm.fshr.i32(i32 %_, i32 %x, i32 %y)
156152
%lshr = lshr i32 %x, %y

0 commit comments

Comments
 (0)