; RV64I-LABEL: gorc1_i32:
; RV64I: # %bb.0:
; RV64I-NEXT: slli a1, a0, 1
-; RV64I-NEXT: lui a2, 171
-; RV64I-NEXT: addiw a2, a2, -1365
-; RV64I-NEXT: slli a2, a2, 12
-; RV64I-NEXT: addi a2, a2, -1366
+; RV64I-NEXT: lui a2, 699051
+; RV64I-NEXT: addiw a2, a2, -1366
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a2, a0, 1
; RV64I-NEXT: lui a3, 349525
; RV64I-LABEL: gorc2_i32:
; RV64I: # %bb.0:
; RV64I-NEXT: slli a1, a0, 2
-; RV64I-NEXT: lui a2, 205
-; RV64I-NEXT: addiw a2, a2, -819
-; RV64I-NEXT: slli a2, a2, 12
-; RV64I-NEXT: addi a2, a2, -820
+; RV64I-NEXT: lui a2, 838861
+; RV64I-NEXT: addiw a2, a2, -820
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a2, a0, 2
; RV64I-NEXT: lui a3, 209715
; RV64I-NEXT: or a0, a2, a0
; RV64I-NEXT: or a0, a0, a1
; RV64I-NEXT: slli a1, a0, 2
-; RV64I-NEXT: lui a2, 205
-; RV64I-NEXT: addiw a2, a2, -819
-; RV64I-NEXT: slli a2, a2, 12
-; RV64I-NEXT: addi a2, a2, -820
+; RV64I-NEXT: lui a2, 838861
+; RV64I-NEXT: addiw a2, a2, -820
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a2, a0, 2
; RV64I-NEXT: lui a3, 209715
; RV64I-LABEL: gorc4_i32:
; RV64I: # %bb.0:
; RV64I-NEXT: slli a1, a0, 4
-; RV64I-NEXT: lui a2, 241
-; RV64I-NEXT: addiw a2, a2, -241
-; RV64I-NEXT: slli a2, a2, 12
-; RV64I-NEXT: addi a2, a2, 240
+; RV64I-NEXT: lui a2, 986895
+; RV64I-NEXT: addiw a2, a2, 240
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a2, a0, 4
; RV64I-NEXT: lui a3, 61681
; RV64I-NEXT: or a0, a2, a0
; RV64I-NEXT: or a0, a0, a1
; RV64I-NEXT: slli a1, a0, 4
-; RV64I-NEXT: lui a2, 241
-; RV64I-NEXT: addiw a2, a2, -241
-; RV64I-NEXT: slli a2, a2, 12
-; RV64I-NEXT: addi a2, a2, 240
+; RV64I-NEXT: lui a2, 986895
+; RV64I-NEXT: addiw a2, a2, 240
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a2, a0, 4
; RV64I-NEXT: lui a3, 61681
; RV64I-NEXT: or a0, a2, a0
; RV64I-NEXT: or a0, a0, a1
; RV64I-NEXT: slli a1, a0, 4
-; RV64I-NEXT: lui a2, 241
-; RV64I-NEXT: addiw a2, a2, -241
-; RV64I-NEXT: slli a2, a2, 12
-; RV64I-NEXT: addi a2, a2, 240
+; RV64I-NEXT: lui a2, 986895
+; RV64I-NEXT: addiw a2, a2, 240
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a2, a0, 4
; RV64I-NEXT: lui a3, 61681
; RV64I-NEXT: or a0, a2, a0
; RV64I-NEXT: or a0, a0, a1
; RV64I-NEXT: slli a1, a0, 4
-; RV64I-NEXT: lui a2, 241
-; RV64I-NEXT: addiw a2, a2, -241
-; RV64I-NEXT: slli a2, a2, 12
-; RV64I-NEXT: addi a2, a2, 240
+; RV64I-NEXT: lui a2, 986895
+; RV64I-NEXT: addiw a2, a2, 240
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a2, a0, 4
; RV64I-NEXT: lui a3, 61681
; RV64I-LABEL: gorc8_i32:
; RV64I: # %bb.0:
; RV64I-NEXT: slli a1, a0, 8
-; RV64I-NEXT: lui a2, 16
-; RV64I-NEXT: addiw a2, a2, -255
-; RV64I-NEXT: slli a2, a2, 16
-; RV64I-NEXT: addi a2, a2, -256
+; RV64I-NEXT: lui a2, 1044496
+; RV64I-NEXT: addiw a2, a2, -256
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a2, a0, 8
; RV64I-NEXT: lui a3, 4080
; RV64I-NEXT: lui a2, 838861
; RV64I-NEXT: addiw a2, a2, -820
; RV64I-NEXT: and a1, a1, a2
-; RV64I-NEXT: srli a2, a0, 2
-; RV64I-NEXT: lui a3, 209715
-; RV64I-NEXT: addiw a3, a3, 819
-; RV64I-NEXT: and a2, a2, a3
-; RV64I-NEXT: or a0, a2, a0
+; RV64I-NEXT: srli a3, a0, 2
+; RV64I-NEXT: lui a4, 209715
+; RV64I-NEXT: addiw a4, a4, 819
+; RV64I-NEXT: and a3, a3, a4
+; RV64I-NEXT: or a0, a3, a0
; RV64I-NEXT: or a0, a0, a1
; RV64I-NEXT: slli a1, a0, 2
-; RV64I-NEXT: lui a2, 205
-; RV64I-NEXT: addiw a2, a2, -819
-; RV64I-NEXT: slli a2, a2, 12
-; RV64I-NEXT: addi a2, a2, -820
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a2, a0, 2
-; RV64I-NEXT: and a2, a2, a3
+; RV64I-NEXT: and a2, a2, a4
; RV64I-NEXT: or a0, a2, a0
; RV64I-NEXT: or a0, a0, a1
; RV64I-NEXT: sext.w a0, a0
; RV64I-NEXT: lui a2, 699051
; RV64I-NEXT: addiw a2, a2, -1366
; RV64I-NEXT: and a1, a1, a2
-; RV64I-NEXT: srli a2, a0, 1
-; RV64I-NEXT: lui a3, 349525
-; RV64I-NEXT: addiw a3, a3, 1365
-; RV64I-NEXT: and a2, a2, a3
-; RV64I-NEXT: or a0, a2, a0
+; RV64I-NEXT: srli a3, a0, 1
+; RV64I-NEXT: lui a4, 349525
+; RV64I-NEXT: addiw a4, a4, 1365
+; RV64I-NEXT: and a3, a3, a4
+; RV64I-NEXT: or a0, a3, a0
; RV64I-NEXT: or a0, a0, a1
; RV64I-NEXT: slli a1, a0, 2
-; RV64I-NEXT: lui a2, 838861
-; RV64I-NEXT: addiw a2, a2, -820
-; RV64I-NEXT: and a1, a1, a2
-; RV64I-NEXT: srli a2, a0, 2
-; RV64I-NEXT: lui a4, 209715
-; RV64I-NEXT: addiw a4, a4, 819
-; RV64I-NEXT: and a2, a2, a4
-; RV64I-NEXT: or a0, a2, a0
+; RV64I-NEXT: lui a3, 838861
+; RV64I-NEXT: addiw a3, a3, -820
+; RV64I-NEXT: and a1, a1, a3
+; RV64I-NEXT: srli a3, a0, 2
+; RV64I-NEXT: lui a5, 209715
+; RV64I-NEXT: addiw a5, a5, 819
+; RV64I-NEXT: and a3, a3, a5
+; RV64I-NEXT: or a0, a3, a0
; RV64I-NEXT: or a0, a0, a1
; RV64I-NEXT: slli a1, a0, 1
-; RV64I-NEXT: lui a2, 171
-; RV64I-NEXT: addiw a2, a2, -1365
-; RV64I-NEXT: slli a2, a2, 12
-; RV64I-NEXT: addi a2, a2, -1366
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a2, a0, 1
-; RV64I-NEXT: and a2, a2, a3
+; RV64I-NEXT: and a2, a2, a4
; RV64I-NEXT: or a0, a2, a0
; RV64I-NEXT: or a0, a0, a1
; RV64I-NEXT: sext.w a0, a0
; RV64I-LABEL: grev1_i32:
; RV64I: # %bb.0:
; RV64I-NEXT: slli a1, a0, 1
-; RV64I-NEXT: lui a2, 171
-; RV64I-NEXT: addiw a2, a2, -1365
-; RV64I-NEXT: slli a2, a2, 12
-; RV64I-NEXT: addi a2, a2, -1366
+; RV64I-NEXT: lui a2, 699051
+; RV64I-NEXT: addiw a2, a2, -1366
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a0, a0, 1
; RV64I-NEXT: lui a2, 349525
; RV64I-LABEL: grev2_i32:
; RV64I: # %bb.0:
; RV64I-NEXT: slli a1, a0, 2
-; RV64I-NEXT: lui a2, 205
-; RV64I-NEXT: addiw a2, a2, -819
-; RV64I-NEXT: slli a2, a2, 12
-; RV64I-NEXT: addi a2, a2, -820
+; RV64I-NEXT: lui a2, 838861
+; RV64I-NEXT: addiw a2, a2, -820
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a0, a0, 2
; RV64I-NEXT: lui a2, 209715
; RV64I-NEXT: and a0, a0, a2
; RV64I-NEXT: or a0, a1, a0
; RV64I-NEXT: slli a1, a0, 2
-; RV64I-NEXT: lui a2, 205
-; RV64I-NEXT: addiw a2, a2, -819
-; RV64I-NEXT: slli a2, a2, 12
-; RV64I-NEXT: addi a2, a2, -820
+; RV64I-NEXT: lui a2, 838861
+; RV64I-NEXT: addiw a2, a2, -820
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a0, a0, 2
; RV64I-NEXT: lui a2, 209715
; RV64I-LABEL: grev4_i32:
; RV64I: # %bb.0:
; RV64I-NEXT: slli a1, a0, 4
-; RV64I-NEXT: lui a2, 241
-; RV64I-NEXT: addiw a2, a2, -241
-; RV64I-NEXT: slli a2, a2, 12
-; RV64I-NEXT: addi a2, a2, 240
+; RV64I-NEXT: lui a2, 986895
+; RV64I-NEXT: addiw a2, a2, 240
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a0, a0, 4
; RV64I-NEXT: lui a2, 61681
; RV64I-NEXT: and a0, a0, a2
; RV64I-NEXT: or a0, a1, a0
; RV64I-NEXT: slli a1, a0, 4
-; RV64I-NEXT: lui a2, 241
-; RV64I-NEXT: addiw a2, a2, -241
-; RV64I-NEXT: slli a2, a2, 12
-; RV64I-NEXT: addi a2, a2, 240
+; RV64I-NEXT: lui a2, 986895
+; RV64I-NEXT: addiw a2, a2, 240
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a0, a0, 4
; RV64I-NEXT: lui a2, 61681
; RV64I-NEXT: and a0, a0, a2
; RV64I-NEXT: or a0, a1, a0
; RV64I-NEXT: slli a1, a0, 4
-; RV64I-NEXT: lui a2, 241
-; RV64I-NEXT: addiw a2, a2, -241
-; RV64I-NEXT: slli a2, a2, 12
-; RV64I-NEXT: addi a2, a2, 240
+; RV64I-NEXT: lui a2, 986895
+; RV64I-NEXT: addiw a2, a2, 240
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a0, a0, 4
; RV64I-NEXT: lui a2, 61681
; RV64I-NEXT: and a0, a0, a2
; RV64I-NEXT: or a0, a1, a0
; RV64I-NEXT: slli a1, a0, 4
-; RV64I-NEXT: lui a2, 241
-; RV64I-NEXT: addiw a2, a2, -241
-; RV64I-NEXT: slli a2, a2, 12
-; RV64I-NEXT: addi a2, a2, 240
+; RV64I-NEXT: lui a2, 986895
+; RV64I-NEXT: addiw a2, a2, 240
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a0, a0, 4
; RV64I-NEXT: lui a2, 61681
; RV64I-LABEL: grev8_i32:
; RV64I: # %bb.0:
; RV64I-NEXT: slli a1, a0, 8
-; RV64I-NEXT: lui a2, 16
-; RV64I-NEXT: addiw a2, a2, -255
-; RV64I-NEXT: slli a2, a2, 16
-; RV64I-NEXT: addi a2, a2, -256
+; RV64I-NEXT: lui a2, 1044496
+; RV64I-NEXT: addiw a2, a2, -256
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a0, a0, 8
; RV64I-NEXT: lui a2, 4080
; RV64I-NEXT: and a0, a0, a2
; RV64I-NEXT: or a0, a1, a0
; RV64I-NEXT: slli a1, a0, 1
-; RV64I-NEXT: lui a2, 171
-; RV64I-NEXT: addiw a2, a2, -1365
-; RV64I-NEXT: slli a2, a2, 12
-; RV64I-NEXT: addi a2, a2, -1366
+; RV64I-NEXT: lui a2, 699051
+; RV64I-NEXT: addiw a2, a2, -1366
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a0, a0, 1
; RV64I-NEXT: lui a2, 349525
; RV64I-NEXT: addiw a2, a2, -1366
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a0, a0, 1
-; RV64I-NEXT: lui a2, 349525
-; RV64I-NEXT: addiw a2, a2, 1365
-; RV64I-NEXT: and a0, a0, a2
+; RV64I-NEXT: lui a3, 349525
+; RV64I-NEXT: addiw a3, a3, 1365
+; RV64I-NEXT: and a0, a0, a3
; RV64I-NEXT: or a0, a1, a0
; RV64I-NEXT: slli a1, a0, 2
-; RV64I-NEXT: lui a3, 838861
-; RV64I-NEXT: addiw a3, a3, -820
-; RV64I-NEXT: and a1, a1, a3
+; RV64I-NEXT: lui a4, 838861
+; RV64I-NEXT: addiw a4, a4, -820
+; RV64I-NEXT: and a1, a1, a4
; RV64I-NEXT: srli a0, a0, 2
-; RV64I-NEXT: lui a3, 209715
-; RV64I-NEXT: addiw a3, a3, 819
-; RV64I-NEXT: and a0, a0, a3
+; RV64I-NEXT: lui a4, 209715
+; RV64I-NEXT: addiw a4, a4, 819
+; RV64I-NEXT: and a0, a0, a4
; RV64I-NEXT: or a0, a1, a0
; RV64I-NEXT: slli a1, a0, 1
-; RV64I-NEXT: lui a3, 171
-; RV64I-NEXT: addiw a3, a3, -1365
-; RV64I-NEXT: slli a3, a3, 12
-; RV64I-NEXT: addi a3, a3, -1366
-; RV64I-NEXT: and a1, a1, a3
+; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a0, a0, 1
-; RV64I-NEXT: and a0, a0, a2
+; RV64I-NEXT: and a0, a0, a3
; RV64I-NEXT: or a0, a1, a0
; RV64I-NEXT: sext.w a0, a0
; RV64I-NEXT: ret
; RV64I-NEXT: addiw a4, a4, -820
; RV64I-NEXT: and a1, a1, a4
; RV64I-NEXT: srli a0, a0, 2
-; RV64I-NEXT: lui a4, 209715
-; RV64I-NEXT: addiw a4, a4, 819
-; RV64I-NEXT: and a0, a0, a4
+; RV64I-NEXT: lui a5, 209715
+; RV64I-NEXT: addiw a5, a5, 819
+; RV64I-NEXT: and a0, a0, a5
; RV64I-NEXT: or a0, a1, a0
; RV64I-NEXT: slli a1, a0, 1
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: and a0, a0, a3
; RV64I-NEXT: or a0, a1, a0
; RV64I-NEXT: slli a1, a0, 2
-; RV64I-NEXT: lui a2, 205
-; RV64I-NEXT: addiw a2, a2, -819
-; RV64I-NEXT: slli a2, a2, 12
-; RV64I-NEXT: addi a2, a2, -820
-; RV64I-NEXT: and a1, a1, a2
+; RV64I-NEXT: and a1, a1, a4
; RV64I-NEXT: srli a0, a0, 2
-; RV64I-NEXT: and a0, a0, a4
+; RV64I-NEXT: and a0, a0, a5
; RV64I-NEXT: or a0, a1, a0
; RV64I-NEXT: sext.w a0, a0
; RV64I-NEXT: ret
; RV64I-NEXT: or a0, a0, a2
; RV64I-NEXT: or a0, a0, a1
; RV64I-NEXT: srli a1, a0, 16
-; RV64I-NEXT: addi a2, zero, 1
-; RV64I-NEXT: slli a2, a2, 32
-; RV64I-NEXT: addi a2, a2, -1
-; RV64I-NEXT: slli a2, a2, 16
+; RV64I-NEXT: lui a2, 1048560
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a0, a0, 48
; RV64I-NEXT: or a0, a0, a1
; RV64I-NEXT: or a0, a0, a2
; RV64I-NEXT: or a0, a0, a1
; RV64I-NEXT: srli a1, a0, 16
-; RV64I-NEXT: addi a2, zero, 1
-; RV64I-NEXT: slli a2, a2, 32
-; RV64I-NEXT: addi a2, a2, -1
-; RV64I-NEXT: slli a2, a2, 16
+; RV64I-NEXT: lui a2, 1048560
; RV64I-NEXT: and a1, a1, a2
; RV64I-NEXT: srli a0, a0, 48
; RV64I-NEXT: or a0, a1, a0
; RV32I-NEXT: lh a1, 4(a1)
; RV32I-NEXT: srli a4, a2, 26
; RV32I-NEXT: add a4, a2, a4
-; RV32I-NEXT: lui a6, 16
-; RV32I-NEXT: addi a5, a6, -64
-; RV32I-NEXT: and a4, a4, a5
+; RV32I-NEXT: andi a4, a4, -64
; RV32I-NEXT: sub s2, a2, a4
; RV32I-NEXT: srli a2, a1, 27
; RV32I-NEXT: add a2, a1, a2
-; RV32I-NEXT: addi a4, a6, -32
-; RV32I-NEXT: and a2, a2, a4
+; RV32I-NEXT: andi a2, a2, -32
; RV32I-NEXT: sub s3, a1, a2
; RV32I-NEXT: srli a1, a3, 29
; RV32I-NEXT: add a1, a3, a1
-; RV32I-NEXT: addi a2, a6, -8
-; RV32I-NEXT: and a1, a1, a2
+; RV32I-NEXT: andi a1, a1, -8
; RV32I-NEXT: sub s1, a3, a1
; RV32I-NEXT: addi a1, zero, 95
; RV32I-NEXT: call __modsi3@plt
;
; RV32IM-LABEL: dont_fold_srem_power_of_two:
; RV32IM: # %bb.0:
-; RV32IM-NEXT: lh a6, 8(a1)
+; RV32IM-NEXT: lh a2, 8(a1)
; RV32IM-NEXT: lh a3, 4(a1)
; RV32IM-NEXT: lh a4, 12(a1)
; RV32IM-NEXT: lh a1, 0(a1)
; RV32IM-NEXT: addi a5, a5, 389
; RV32IM-NEXT: mulh a5, a4, a5
; RV32IM-NEXT: add a5, a5, a4
-; RV32IM-NEXT: srli a2, a5, 31
+; RV32IM-NEXT: srli a6, a5, 31
; RV32IM-NEXT: srli a5, a5, 6
-; RV32IM-NEXT: add a2, a5, a2
+; RV32IM-NEXT: add a6, a5, a6
; RV32IM-NEXT: addi a5, zero, 95
-; RV32IM-NEXT: mul a2, a2, a5
-; RV32IM-NEXT: sub a7, a4, a2
-; RV32IM-NEXT: srli a4, a1, 26
-; RV32IM-NEXT: add a4, a1, a4
-; RV32IM-NEXT: lui a5, 16
-; RV32IM-NEXT: addi a2, a5, -64
-; RV32IM-NEXT: and a2, a4, a2
-; RV32IM-NEXT: sub a1, a1, a2
-; RV32IM-NEXT: srli a2, a3, 27
-; RV32IM-NEXT: add a2, a3, a2
-; RV32IM-NEXT: addi a4, a5, -32
-; RV32IM-NEXT: and a2, a2, a4
-; RV32IM-NEXT: sub a2, a3, a2
-; RV32IM-NEXT: srli a3, a6, 29
-; RV32IM-NEXT: add a3, a6, a3
-; RV32IM-NEXT: addi a4, a5, -8
-; RV32IM-NEXT: and a3, a3, a4
-; RV32IM-NEXT: sub a3, a6, a3
-; RV32IM-NEXT: sh a3, 4(a0)
-; RV32IM-NEXT: sh a2, 2(a0)
+; RV32IM-NEXT: mul a5, a6, a5
+; RV32IM-NEXT: sub a4, a4, a5
+; RV32IM-NEXT: srli a5, a1, 26
+; RV32IM-NEXT: add a5, a1, a5
+; RV32IM-NEXT: andi a5, a5, -64
+; RV32IM-NEXT: sub a1, a1, a5
+; RV32IM-NEXT: srli a5, a3, 27
+; RV32IM-NEXT: add a5, a3, a5
+; RV32IM-NEXT: andi a5, a5, -32
+; RV32IM-NEXT: sub a3, a3, a5
+; RV32IM-NEXT: srli a5, a2, 29
+; RV32IM-NEXT: add a5, a2, a5
+; RV32IM-NEXT: andi a5, a5, -8
+; RV32IM-NEXT: sub a2, a2, a5
+; RV32IM-NEXT: sh a2, 4(a0)
+; RV32IM-NEXT: sh a3, 2(a0)
; RV32IM-NEXT: sh a1, 0(a0)
-; RV32IM-NEXT: sh a7, 6(a0)
+; RV32IM-NEXT: sh a4, 6(a0)
; RV32IM-NEXT: ret
;
; RV64I-LABEL: dont_fold_srem_power_of_two:
; RV64I-NEXT: lh a1, 8(a1)
; RV64I-NEXT: srli a4, a2, 58
; RV64I-NEXT: add a4, a2, a4
-; RV64I-NEXT: lui a6, 16
-; RV64I-NEXT: addiw a5, a6, -64
-; RV64I-NEXT: and a4, a4, a5
+; RV64I-NEXT: andi a4, a4, -64
; RV64I-NEXT: sub s2, a2, a4
; RV64I-NEXT: srli a2, a1, 59
; RV64I-NEXT: add a2, a1, a2
-; RV64I-NEXT: addiw a4, a6, -32
-; RV64I-NEXT: and a2, a2, a4
+; RV64I-NEXT: andi a2, a2, -32
; RV64I-NEXT: sub s3, a1, a2
; RV64I-NEXT: srli a1, a3, 61
; RV64I-NEXT: add a1, a3, a1
-; RV64I-NEXT: addiw a2, a6, -8
-; RV64I-NEXT: and a1, a1, a2
+; RV64I-NEXT: andi a1, a1, -8
; RV64I-NEXT: sub s1, a3, a1
; RV64I-NEXT: addi a1, zero, 95
; RV64I-NEXT: call __moddi3@plt
; RV64IM-NEXT: add a2, a5, a2
; RV64IM-NEXT: addi a5, zero, 95
; RV64IM-NEXT: mul a2, a2, a5
-; RV64IM-NEXT: sub a7, a1, a2
+; RV64IM-NEXT: sub a1, a1, a2
; RV64IM-NEXT: srli a2, a4, 58
; RV64IM-NEXT: add a2, a4, a2
-; RV64IM-NEXT: lui a5, 16
-; RV64IM-NEXT: addiw a1, a5, -64
-; RV64IM-NEXT: and a1, a2, a1
-; RV64IM-NEXT: sub a1, a4, a1
-; RV64IM-NEXT: srli a2, a3, 59
-; RV64IM-NEXT: add a2, a3, a2
-; RV64IM-NEXT: addiw a4, a5, -32
-; RV64IM-NEXT: and a2, a2, a4
-; RV64IM-NEXT: sub a2, a3, a2
-; RV64IM-NEXT: srli a3, a6, 61
-; RV64IM-NEXT: add a3, a6, a3
-; RV64IM-NEXT: addiw a4, a5, -8
-; RV64IM-NEXT: and a3, a3, a4
-; RV64IM-NEXT: sub a3, a6, a3
-; RV64IM-NEXT: sh a3, 4(a0)
-; RV64IM-NEXT: sh a2, 2(a0)
-; RV64IM-NEXT: sh a1, 0(a0)
-; RV64IM-NEXT: sh a7, 6(a0)
+; RV64IM-NEXT: andi a2, a2, -64
+; RV64IM-NEXT: sub a2, a4, a2
+; RV64IM-NEXT: srli a4, a3, 59
+; RV64IM-NEXT: add a4, a3, a4
+; RV64IM-NEXT: andi a4, a4, -32
+; RV64IM-NEXT: sub a3, a3, a4
+; RV64IM-NEXT: srli a4, a6, 61
+; RV64IM-NEXT: add a4, a6, a4
+; RV64IM-NEXT: andi a4, a4, -8
+; RV64IM-NEXT: sub a4, a6, a4
+; RV64IM-NEXT: sh a4, 4(a0)
+; RV64IM-NEXT: sh a3, 2(a0)
+; RV64IM-NEXT: sh a2, 0(a0)
+; RV64IM-NEXT: sh a1, 6(a0)
; RV64IM-NEXT: ret
%1 = srem <4 x i16> %x, <i16 64, i16 32, i16 8, i16 95>
ret <4 x i16> %1