Skip to content

[GlobalISel] Preserve original flags of output instructions in matchtable #130937

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
Mar 13, 2025

Conversation

Pierre-vh
Copy link
Contributor

@Pierre-vh Pierre-vh commented Mar 12, 2025

We don't have any combine in trunk that uses output MIFlags when using MIR patterns, but I tried writing one and noticed that the flags were lost.

The reason is that the MatchTableExecutor was overwriting the flags.

…table

We don't have any combine in trunk that uses output MIFlags when using MIR pattenrs, but I tried writing one and noticed that the flags were lost.

The reason is that the MatchTableExecutor was overwriting the flags.
@llvmbot
Copy link
Member

llvmbot commented Mar 12, 2025

@llvm/pr-subscribers-llvm-globalisel

Author: Pierre van Houtryve (Pierre-vh)

Changes

We don't have any combine in trunk that uses output MIFlags when using MIR pattenrs, but I tried writing one and noticed that the flags were lost.

The reason is that the MatchTableExecutor was overwriting the flags.


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

1 Files Affected:

  • (modified) llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutorImpl.h (+1-1)
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutorImpl.h b/llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutorImpl.h
index 2c57f2b5aa029..654112e86e873 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutorImpl.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutorImpl.h
@@ -80,7 +80,7 @@ bool GIMatchTableExecutor::executeMatchTable(
     for (auto MIB : OutMIs) {
       // Set the NoFPExcept flag when no original matched instruction could
       // raise an FP exception, but the new instruction potentially might.
-      uint16_t MIBFlags = Flags;
+      uint16_t MIBFlags = Flags | MIB.getInstr()->getFlags();
       if (NoFPException && MIB->mayRaiseFPException())
         MIBFlags |= MachineInstr::NoFPExcept;
       if (Observer)

@Pierre-vh Pierre-vh merged commit 46739be into llvm:main Mar 13, 2025
13 checks passed
@Pierre-vh Pierre-vh deleted the mt-drops-miflags branch March 13, 2025 10:43
@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 13, 2025

LLVM Buildbot has detected a new failure on builder arc-builder running on arc-worker while building llvm at step 6 "test-build-unified-tree-check-all".

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

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: 1200 seconds without output running [b'ninja', b'check-all'], attempting to kill
...
17.720 [1/18/59] Linking CXX executable unittests/MI/MITests
18.007 [1/17/60] Linking CXX executable unittests/Transforms/Vectorize/VectorizeTests
18.205 [1/16/61] Linking CXX executable unittests/tools/llvm-profdata/LLVMProfdataTests
18.400 [1/15/62] Linking CXX executable unittests/ExecutionEngine/MCJIT/MCJITTests
18.838 [1/14/63] Linking CXX executable unittests/IR/IRTests
19.343 [1/13/64] Linking CXX executable unittests/tools/llvm-cfi-verify/CFIVerifyTests
19.351 [1/12/65] Linking CXX executable unittests/Target/TargetMachineCTests
19.690 [1/11/66] Linking CXX executable unittests/Transforms/Coroutines/CoroTests
19.691 [1/10/67] Linking CXX executable unittests/Transforms/Instrumentation/InstrumentationTests
19.758 [1/9/68] Linking CXX executable unittests/Passes/PassBuilderBindings/PassesBindingsTests
command timed out: 1200 seconds without output running [b'ninja', b'check-all'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=1220.498659

frederik-h pushed a commit to frederik-h/llvm-project that referenced this pull request Mar 18, 2025
…able (llvm#130937)

We don't have any combine in trunk that uses output MIFlags when using
MIR patterns, but I tried writing one and noticed that the flags were
lost.

The reason is that the MatchTableExecutor was overwriting the flags.
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.

4 participants