[llvm] [X86] Use RORX over SHR imm (PR #77964)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 18 05:58:07 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff fc6faa1113e9069f41b5500db051210af0eea843 8a4753177d47dbac3ce6a679065d7a11343a69c5 -- llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index 09724363e1..e59b895df7 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -4237,28 +4237,38 @@ bool X86DAGToDAGISel::rightShiftUncloberFlags(SDNode *N) {
printf("Not vector\n");
unsigned OpSize;
- if (VT == MVT::i64) OpSize = 64;
- else if (VT == MVT::i32) OpSize = 32;
- else if (VT == MVT::i16) OpSize = 16;
- else if (VT == MVT::i8) return false; // i8 shift can't be truncated.
- else llvm_unreachable("Unexpected shift size");
+ if (VT == MVT::i64)
+ OpSize = 64;
+ else if (VT == MVT::i32)
+ OpSize = 32;
+ else if (VT == MVT::i16)
+ OpSize = 16;
+ else if (VT == MVT::i8)
+ return false; // i8 shift can't be truncated.
+ else
+ llvm_unreachable("Unexpected shift size");
printf("Good OpSize\n");
unsigned TruncateSize = 0;
// This only works when the result is truncated.
for (const SDNode *User : N->uses()) {
- //printf("Looking at a use. TargetOpcode is %u\n", User->isTargetOpcode());
+ // printf("Looking at a use. TargetOpcode is %u\n", User->isTargetOpcode());
auto name = User->getOperationName(CurDAG);
- printf("Looking at a thing %s %u %u\n", name.c_str(), User->getOpcode(), TargetOpcode::EXTRACT_SUBREG);
+ printf("Looking at a thing %s %u %u\n", name.c_str(), User->getOpcode(),
+ TargetOpcode::EXTRACT_SUBREG);
if (User->getMachineOpcode() != TargetOpcode::EXTRACT_SUBREG)
return false;
printf("It's an EXTRACT_SUBREG\n");
EVT TuncateType = User->getValueType(0);
- if (TuncateType == MVT::i32) TruncateSize = std::max(TruncateSize, 32U);
- else if (TuncateType == MVT::i16) TruncateSize = std::max(TruncateSize, 16U);
- else if (TuncateType == MVT::i8) TruncateSize = std::max(TruncateSize, 8U);
- else return false;
+ if (TuncateType == MVT::i32)
+ TruncateSize = std::max(TruncateSize, 32U);
+ else if (TuncateType == MVT::i16)
+ TruncateSize = std::max(TruncateSize, 16U);
+ else if (TuncateType == MVT::i8)
+ TruncateSize = std::max(TruncateSize, 8U);
+ else
+ return false;
}
printf("Truncates are fine\n");
if (TruncateSize >= OpSize)
@@ -4279,7 +4289,10 @@ bool X86DAGToDAGISel::rightShiftUncloberFlags(SDNode *N) {
// Make the replacement.
SDLoc DL(N);
MVT RotateSize = OpSize == 64 ? MVT::i64 : MVT::i32;
- SDNode* Replacement = CurDAG->getNode(ISD::ROTR, DL, RotateSize, N->getOperand(0), N->getOperand(1)).getNode();
+ SDNode *Replacement = CurDAG
+ ->getNode(ISD::ROTR, DL, RotateSize,
+ N->getOperand(0), N->getOperand(1))
+ .getNode();
ReplaceNode(N, Replacement);
CurDAG->RemoveDeadNode(N);
SelectCode(Replacement);
``````````
</details>
https://github.com/llvm/llvm-project/pull/77964
More information about the llvm-commits
mailing list