[PATCH] D140036: [RISCV] Add IsSignExtendingOpW to the Zknh SHA256 instructions.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 14 11:10:24 PST 2022
craig.topper created this revision.
craig.topper added reviewers: asb, reames, achieveartificialintelligence, luismarques.
Herald added subscribers: sunshaoce, VincentWu, StephenFan, vkmr, frasercrmck, evandro, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.
On RV64 these instructions produce a 32-bit value and sign extend
to 64-bits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D140036
Files:
llvm/lib/Target/RISCV/RISCVInstrInfoZk.td
llvm/test/CodeGen/RISCV/sextw-removal.ll
Index: llvm/test/CodeGen/RISCV/sextw-removal.ll
===================================================================
--- llvm/test/CodeGen/RISCV/sextw-removal.ll
+++ llvm/test/CodeGen/RISCV/sextw-removal.ll
@@ -1,9 +1,9 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple=riscv64 -mattr=+m,+f -target-abi=lp64f \
+; RUN: llc < %s -mtriple=riscv64 -mattr=+m,+f,+zknh -target-abi=lp64f \
; RUN: | FileCheck %s --check-prefixes=CHECK,RV64I
-; RUN: llc < %s -mtriple=riscv64 -mattr=+m,+zbb,+f -target-abi=lp64f \
+; RUN: llc < %s -mtriple=riscv64 -mattr=+m,+zbb,+f,+zknh -target-abi=lp64f \
; RUN: | FileCheck %s --check-prefixes=CHECK,RV64ZBB
-; RUN: llc < %s -mtriple=riscv64 -mattr=+m,+zbb,+f -target-abi=lp64f \
+; RUN: llc < %s -mtriple=riscv64 -mattr=+m,+zbb,+f,+zknh -target-abi=lp64f \
; RUN: -riscv-disable-sextw-removal | FileCheck %s --check-prefix=NOREMOVAL
define void @test1(i32 signext %arg, i32 signext %arg1) nounwind {
@@ -1266,3 +1266,63 @@
ret void
}
declare zeroext i16 @bat(i32 signext)
+
+define void @test18(i32 signext %arg, i32 signext %arg1) nounwind {
+; CHECK-LABEL: test18:
+; CHECK: # %bb.0: # %bb
+; CHECK-NEXT: addi sp, sp, -32
+; CHECK-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
+; CHECK-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
+; CHECK-NEXT: sd s1, 8(sp) # 8-byte Folded Spill
+; CHECK-NEXT: mv s0, a1
+; CHECK-NEXT: sha256sig0 s1, a1
+; CHECK-NEXT: .LBB21_1: # %bb2
+; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
+; CHECK-NEXT: mv a0, s1
+; CHECK-NEXT: call bar at plt
+; CHECK-NEXT: sllw s1, s1, s0
+; CHECK-NEXT: bnez a0, .LBB21_1
+; CHECK-NEXT: # %bb.2: # %bb7
+; CHECK-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
+; CHECK-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
+; CHECK-NEXT: ld s1, 8(sp) # 8-byte Folded Reload
+; CHECK-NEXT: addi sp, sp, 32
+; CHECK-NEXT: ret
+;
+; NOREMOVAL-LABEL: test18:
+; NOREMOVAL: # %bb.0: # %bb
+; NOREMOVAL-NEXT: addi sp, sp, -32
+; NOREMOVAL-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
+; NOREMOVAL-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
+; NOREMOVAL-NEXT: sd s1, 8(sp) # 8-byte Folded Spill
+; NOREMOVAL-NEXT: mv s0, a1
+; NOREMOVAL-NEXT: sha256sig0 s1, a1
+; NOREMOVAL-NEXT: .LBB21_1: # %bb2
+; NOREMOVAL-NEXT: # =>This Inner Loop Header: Depth=1
+; NOREMOVAL-NEXT: sext.w a0, s1
+; NOREMOVAL-NEXT: call bar at plt
+; NOREMOVAL-NEXT: sllw s1, s1, s0
+; NOREMOVAL-NEXT: bnez a0, .LBB21_1
+; NOREMOVAL-NEXT: # %bb.2: # %bb7
+; NOREMOVAL-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
+; NOREMOVAL-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
+; NOREMOVAL-NEXT: ld s1, 8(sp) # 8-byte Folded Reload
+; NOREMOVAL-NEXT: addi sp, sp, 32
+; NOREMOVAL-NEXT: ret
+bb:
+ %sext = sext i32 %arg1 to i64
+ %i = call i64 @llvm.riscv.sha256sig0.i64(i64 %sext)
+ %trunc = trunc i64 %i to i32
+ br label %bb2
+
+bb2: ; preds = %bb2, %bb
+ %i3 = phi i32 [ %trunc, %bb ], [ %i5, %bb2 ]
+ %i4 = tail call signext i32 @bar(i32 signext %i3)
+ %i5 = shl i32 %i3, %arg1
+ %i6 = icmp eq i32 %i4, 0
+ br i1 %i6, label %bb7, label %bb2
+
+bb7: ; preds = %bb2
+ ret void
+}
+declare i64 @llvm.riscv.sha256sig0.i64(i64)
Index: llvm/lib/Target/RISCV/RISCVInstrInfoZk.td
===================================================================
--- llvm/lib/Target/RISCV/RISCVInstrInfoZk.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoZk.td
@@ -96,7 +96,7 @@
def AES64ESM : ALU_rr<0b0011011, 0b000, "aes64esm">;
} // Predicates = [HasStdExtZkne, IsRV64]
-let Predicates = [HasStdExtZknh] in {
+let Predicates = [HasStdExtZknh], IsSignExtendingOpW = 1 in {
def SHA256SIG0 : RVKUnary<0b000100000010, 0b001, "sha256sig0">;
def SHA256SIG1 : RVKUnary<0b000100000011, 0b001, "sha256sig1">;
def SHA256SUM0 : RVKUnary<0b000100000000, 0b001, "sha256sum0">;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140036.482939.patch
Type: text/x-patch
Size: 3962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221214/9da08cea/attachment.bin>
More information about the llvm-commits
mailing list