Skip to content

[RISCV] Use RISCVII::getVecPolicyOpNum instead of making assumptions. NFC #144175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 14, 2025

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Jun 14, 2025

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Jun 14, 2025

@llvm/pr-subscribers-backend-risc-v

Author: Craig Topper (topperc)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/144175.diff

1 Files Affected:

  • (modified) llvm/lib/Target/RISCV/RISCVInstrInfo.cpp (+6-3)
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index e5d29e1a8b476..0c4069c062ca8 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -3696,7 +3696,8 @@ bool RISCVInstrInfo::findCommutedOpIndices(const MachineInstr &MI,
   case CASE_VMA_OPCODE_LMULS(NMSAC, VV): {
     // If the tail policy is undisturbed we can't commute.
     assert(RISCVII::hasVecPolicyOp(MI.getDesc().TSFlags));
-    if ((MI.getOperand(MI.getNumExplicitOperands() - 1).getImm() & 1) == 0)
+    if ((MI.getOperand(RISCVII::getVecPolicyOpNum(MI.getDesc())).getImm() &
+         1) == 0)
       return false;
 
     // For these instructions we can only swap operand 1 and operand 3 by
@@ -3716,7 +3717,8 @@ bool RISCVInstrInfo::findCommutedOpIndices(const MachineInstr &MI,
   case CASE_VMA_OPCODE_LMULS(NMSUB, VV): {
     // If the tail policy is undisturbed we can't commute.
     assert(RISCVII::hasVecPolicyOp(MI.getDesc().TSFlags));
-    if ((MI.getOperand(MI.getNumExplicitOperands() - 1).getImm() & 1) == 0)
+    if ((MI.getOperand(RISCVII::getVecPolicyOpNum(MI.getDesc())).getImm() &
+         1) == 0)
       return false;
 
     // For these instructions we have more freedom. We can commute with the
@@ -4331,7 +4333,8 @@ MachineInstr *RISCVInstrInfo::convertToThreeAddress(MachineInstr &MI,
     // If the tail policy is undisturbed we can't convert.
     assert(RISCVII::hasVecPolicyOp(MI.getDesc().TSFlags) &&
            MI.getNumExplicitOperands() == 6);
-    if ((MI.getOperand(5).getImm() & 1) == 0)
+    if ((MI.getOperand(RISCVII::getVecPolicyOpNum(MI.getDesc())).getImm() &
+         1) == 0)
       return nullptr;
 
     // clang-format off

Copy link
Contributor

@wangpc-pp wangpc-pp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@topperc topperc merged commit 709ba08 into llvm:main Jun 14, 2025
9 checks passed
@topperc topperc deleted the pr/getvecpolicyop branch June 14, 2025 05:18
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 14, 2025

LLVM Buildbot has detected a new failure on builder flang-aarch64-release running on linaro-flang-aarch64-release while building llvm at step 6 "test-build-unified-tree-check-flang".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/172/builds/13180

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-flang) failure: test (failure)
******************** TEST 'Flang :: Semantics/modfile75.F90' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
/home/tcwg-buildbot/worker/flang-aarch64-release/build/bin/flang -c -fhermetic-module-files -DWHICH=1 /home/tcwg-buildbot/worker/flang-aarch64-release/llvm-project/flang/test/Semantics/modfile75.F90 && /home/tcwg-buildbot/worker/flang-aarch64-release/build/bin/flang -c -fhermetic-module-files -DWHICH=2 /home/tcwg-buildbot/worker/flang-aarch64-release/llvm-project/flang/test/Semantics/modfile75.F90 && /home/tcwg-buildbot/worker/flang-aarch64-release/build/bin/flang -fc1 -fdebug-unparse /home/tcwg-buildbot/worker/flang-aarch64-release/llvm-project/flang/test/Semantics/modfile75.F90 | /home/tcwg-buildbot/worker/flang-aarch64-release/build/bin/FileCheck /home/tcwg-buildbot/worker/flang-aarch64-release/llvm-project/flang/test/Semantics/modfile75.F90 # RUN: at line 1
+ /home/tcwg-buildbot/worker/flang-aarch64-release/build/bin/flang -c -fhermetic-module-files -DWHICH=1 /home/tcwg-buildbot/worker/flang-aarch64-release/llvm-project/flang/test/Semantics/modfile75.F90
+ /home/tcwg-buildbot/worker/flang-aarch64-release/build/bin/flang -c -fhermetic-module-files -DWHICH=2 /home/tcwg-buildbot/worker/flang-aarch64-release/llvm-project/flang/test/Semantics/modfile75.F90
+ /home/tcwg-buildbot/worker/flang-aarch64-release/build/bin/FileCheck /home/tcwg-buildbot/worker/flang-aarch64-release/llvm-project/flang/test/Semantics/modfile75.F90
+ /home/tcwg-buildbot/worker/flang-aarch64-release/build/bin/flang -fc1 -fdebug-unparse /home/tcwg-buildbot/worker/flang-aarch64-release/llvm-project/flang/test/Semantics/modfile75.F90
error: Semantic errors in /home/tcwg-buildbot/worker/flang-aarch64-release/llvm-project/flang/test/Semantics/modfile75.F90
/home/tcwg-buildbot/worker/flang-aarch64-release/llvm-project/flang/test/Semantics/modfile75.F90:15:11: error: Must be a constant value
    integer(c_int) n
            ^^^^^
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /home/tcwg-buildbot/worker/flang-aarch64-release/build/bin/FileCheck /home/tcwg-buildbot/worker/flang-aarch64-release/llvm-project/flang/test/Semantics/modfile75.F90

--

********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 14, 2025

LLVM Buildbot has detected a new failure on builder clang-aarch64-sve-vls-2stage running on linaro-g3-02 while building llvm at step 12 "ninja check 2".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/4/builds/7355

Here is the relevant piece of the build log for the reference
Step 12 (ninja check 2) failure: stage 2 checked (failure)
******************** TEST 'Flang :: Semantics/modfile75.F90' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/bin/flang -c -fhermetic-module-files -DWHICH=1 /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/test/Semantics/modfile75.F90 && /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/bin/flang -c -fhermetic-module-files -DWHICH=2 /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/test/Semantics/modfile75.F90 && /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/bin/flang -fc1 -fdebug-unparse /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/test/Semantics/modfile75.F90 | /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/bin/FileCheck /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/test/Semantics/modfile75.F90 # RUN: at line 1
+ /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/bin/flang -c -fhermetic-module-files -DWHICH=1 /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/test/Semantics/modfile75.F90
+ /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/bin/flang -c -fhermetic-module-files -DWHICH=2 /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/test/Semantics/modfile75.F90
+ /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/bin/flang -fc1 -fdebug-unparse /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/test/Semantics/modfile75.F90
+ /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/bin/FileCheck /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/test/Semantics/modfile75.F90
error: Semantic errors in /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/test/Semantics/modfile75.F90
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/test/Semantics/modfile75.F90:15:11: error: Must be a constant value
    integer(c_int) n
            ^^^^^
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/bin/FileCheck /home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/test/Semantics/modfile75.F90

--

********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 14, 2025

LLVM Buildbot has detected a new failure on builder flang-aarch64-dylib running on linaro-flang-aarch64-dylib while building llvm at step 6 "test-build-unified-tree-check-flang".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/50/builds/14089

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-flang) failure: test (failure)
******************** TEST 'Flang :: Semantics/modfile75.F90' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/flang -c -fhermetic-module-files -DWHICH=1 /home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Semantics/modfile75.F90 && /home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/flang -c -fhermetic-module-files -DWHICH=2 /home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Semantics/modfile75.F90 && /home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/flang -fc1 -fdebug-unparse /home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Semantics/modfile75.F90 | /home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/FileCheck /home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Semantics/modfile75.F90 # RUN: at line 1
+ /home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/flang -c -fhermetic-module-files -DWHICH=1 /home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Semantics/modfile75.F90
+ /home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/flang -c -fhermetic-module-files -DWHICH=2 /home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Semantics/modfile75.F90
+ /home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/flang -fc1 -fdebug-unparse /home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Semantics/modfile75.F90
+ /home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/FileCheck /home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Semantics/modfile75.F90
error: Semantic errors in /home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Semantics/modfile75.F90
/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Semantics/modfile75.F90:15:11: error: Must be a constant value
    integer(c_int) n
            ^^^^^
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/FileCheck /home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Semantics/modfile75.F90

--

********************


tomtor pushed a commit to tomtor/llvm-project that referenced this pull request Jun 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants