[llvm] [RISCV] Mark VFIRST and VCPOP as SignExtendingOpW (PR #77022)
Min-Yih Hsu via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 4 16:43:36 PST 2024
================
@@ -28,3 +28,55 @@ body: |
$x11 = COPY %4
PseudoRET
...
+---
+ name: vfirst
+ tracksRegLiveness: true
+ body: |
+ bb.0.entry:
+ liveins: $x10, $v8
+
+ ; CHECK-LABEL: name: vfirst
+ ; CHECK: liveins: $x10, $v8
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:vr = COPY $v8
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gprnox0 = COPY $x10
+ ; CHECK-NEXT: [[PseudoVFIRST_M_B1_:%[0-9]+]]:gpr = PseudoVFIRST_M_B1 [[COPY]], [[COPY1]], 0 /* e8 */
+ ; CHECK-NEXT: [[ADD:%[0-9]+]]:gpr = ADD [[COPY1]], [[PseudoVFIRST_M_B1_]]
+ ; CHECK-NEXT: $x10 = COPY [[ADD]]
+ ; CHECK-NEXT: $x11 = COPY [[PseudoVFIRST_M_B1_]]
+ ; CHECK-NEXT: PseudoRET
+ %0:vr = COPY $v8
+ %1:gprnox0 = COPY $x10
+ %2:gpr = PseudoVFIRST_M_B1 %0:vr, %1:gprnox0, 0
+ %3:gpr = ADD %1, %2
----------------
mshockwave wrote:
If the user of sext only uses the lower 32 bits, RISCVOptWInstrs will remove the sext regardless of the SignExtendingOpW flag (see the `hasAllWUsers` function). Previously, I tried to use `ADD` to create that artificial use, despite using an incorrect syntax (`ADD` was using `%2` not `%4`) it somehow stoped RISCVOptWInstrs from removing sext in absent of SignExtendingOpW.
But even `ADD` is not the best choice as RISCVOptWInstrs transitively looks into the user of `ADD` to determine if only the lower 32 bits are used so we're only pushing off the problem. A better choice would be using `SRLI` with its shift amount greater than 32, which creates an artificial use beyond 32 bits. I'll update the patch accordingly
https://github.com/llvm/llvm-project/pull/77022
More information about the llvm-commits
mailing list