[PATCH] D156081: [RISCV] Add CZERO_EQZ/CZERO_NEZ to computeKnownBitsForTargetNode.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 23 23:10:04 PDT 2023
craig.topper created this revision.
craig.topper added reviewers: asb, reames, wangpc, frasercrmck.
Herald added subscribers: jobnoorman, luke, VincentWu, foad, vkmr, luismarques, 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: eopXD, MaskRay.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156081
Files:
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/xaluo.ll
Index: llvm/test/CodeGen/RISCV/xaluo.ll
===================================================================
--- llvm/test/CodeGen/RISCV/xaluo.ll
+++ llvm/test/CodeGen/RISCV/xaluo.ll
@@ -4395,8 +4395,7 @@
; RV32ZICOND-NEXT: czero.eqz a1, a1, a2
; RV32ZICOND-NEXT: czero.nez a0, a0, a2
; RV32ZICOND-NEXT: or a0, a1, a0
-; RV32ZICOND-NEXT: li a1, 1
-; RV32ZICOND-NEXT: bne a0, a1, .LBB55_2
+; RV32ZICOND-NEXT: beqz a0, .LBB55_2
; RV32ZICOND-NEXT: # %bb.1: # %overflow
; RV32ZICOND-NEXT: li a0, 0
; RV32ZICOND-NEXT: ret
@@ -4769,8 +4768,7 @@
; RV32ZICOND-NEXT: sltu a0, a0, a2
; RV32ZICOND-NEXT: czero.nez a0, a0, a4
; RV32ZICOND-NEXT: or a0, a1, a0
-; RV32ZICOND-NEXT: li a1, 1
-; RV32ZICOND-NEXT: bne a0, a1, .LBB59_2
+; RV32ZICOND-NEXT: beqz a0, .LBB59_2
; RV32ZICOND-NEXT: # %bb.1: # %overflow
; RV32ZICOND-NEXT: li a0, 0
; RV32ZICOND-NEXT: ret
@@ -5602,8 +5600,7 @@
; RV32ZICOND-NEXT: sltu a1, a2, a1
; RV32ZICOND-NEXT: czero.eqz a1, a1, a3
; RV32ZICOND-NEXT: or a0, a1, a0
-; RV32ZICOND-NEXT: li a1, 1
-; RV32ZICOND-NEXT: bne a0, a1, .LBB65_2
+; RV32ZICOND-NEXT: beqz a0, .LBB65_2
; RV32ZICOND-NEXT: # %bb.1: # %overflow
; RV32ZICOND-NEXT: li a0, 0
; RV32ZICOND-NEXT: ret
Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -13716,6 +13716,13 @@
Known = Known.intersectWith(Known2);
break;
}
+ case RISCVISD::CZERO_EQZ:
+ case RISCVISD::CZERO_NEZ:
+ Known = DAG.computeKnownBits(Op.getOperand(0), Depth + 1);
+ // Result is either all zero or operand 0. We can propagate zeros, but not
+ // ones.
+ Known.One.clearAllBits();
+ break;
case RISCVISD::REMUW: {
KnownBits Known2;
Known = DAG.computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156081.543386.patch
Type: text/x-patch
Size: 1953 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230724/01c1201f/attachment.bin>
More information about the llvm-commits
mailing list