File tree Expand file tree Collapse file tree 3 files changed +54
-0
lines changed
src/cmd/compile/internal/ssa Expand file tree Collapse file tree 3 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 782
782
(SRLI [x] (MOVDconst [y])) => (MOVDconst [int64(uint64(y) >> uint32(x))])
783
783
(SRAI [x] (MOVDconst [y])) => (MOVDconst [int64(y) >> uint32(x)])
784
784
785
+ // Combine doubling via addition with shift.
786
+ (SLLI <t> [c] (ADD x x)) && c < t.Size() * 8 - 1 => (SLLI <t> [c+1] x)
787
+ (SLLI <t> [c] (ADD x x)) && c >= t.Size() * 8 - 1 => (MOVDconst [0])
788
+
785
789
// SLTI/SLTIU with constants.
786
790
(SLTI [x] (MOVDconst [y])) => (MOVDconst [b2i(int64(y) < int64(x))])
787
791
(SLTIU [x] (MOVDconst [y])) => (MOVDconst [b2i(uint64(y) < uint64(x))])
Original file line number Diff line number Diff line change @@ -122,27 +122,41 @@ func rshConst64x32(v int64) int64 {
122
122
func lshConst32x1Add (x int32 ) int32 {
123
123
// amd64:"SHLL\t[$]2"
124
124
// loong64:"SLL\t[$]2"
125
+ // riscv64:"SLLI\t[$]2"
125
126
return (x + x ) << 1
126
127
}
127
128
128
129
func lshConst64x1Add (x int64 ) int64 {
129
130
// amd64:"SHLQ\t[$]2"
130
131
// loong64:"SLLV\t[$]2"
132
+ // riscv64:"SLLI\t[$]2"
131
133
return (x + x ) << 1
132
134
}
133
135
134
136
func lshConst32x2Add (x int32 ) int32 {
135
137
// amd64:"SHLL\t[$]3"
136
138
// loong64:"SLL\t[$]3"
139
+ // riscv64:"SLLI\t[$]3"
137
140
return (x + x ) << 2
138
141
}
139
142
140
143
func lshConst64x2Add (x int64 ) int64 {
141
144
// amd64:"SHLQ\t[$]3"
142
145
// loong64:"SLLV\t[$]3"
146
+ // riscv64:"SLLI\t[$]3"
143
147
return (x + x ) << 2
144
148
}
145
149
150
+ func lshConst32x31Add (x int32 ) int32 {
151
+ // riscv64:-"SLLI","MOV\t[$]0"
152
+ return (x + x ) << 31
153
+ }
154
+
155
+ func lshConst64x63Add (x int64 ) int64 {
156
+ // riscv64:-"SLLI","MOV\t[$]0"
157
+ return (x + x ) << 63
158
+ }
159
+
146
160
// ------------------ //
147
161
// masked shifts //
148
162
// ------------------ //
You can’t perform that action at this time.
0 commit comments