[llvm] [llvm][CodeGen] Added a check in CodeGenPrepare::optimizeSwitchType (PR #83322)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 28 11:38:10 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 d82e93e7f129d9e8b72570efdf4a15d6ec3d4336 bcaca8e49e80995493016e3508006b57a484adee -- llvm/lib/CodeGen/CodeGenPrepare.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 39643c17d3..4ddcd38e00 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -7399,9 +7399,9 @@ bool CodeGenPrepare::optimizeSwitchType(SwitchInst *SI) {
}
// If Cond has already a zext or sext don't insert another one.
bool ExtExists = false;
- if(auto *I = dyn_cast<Instruction>(Cond)){
+ if (auto *I = dyn_cast<Instruction>(Cond)) {
unsigned Opc = I->getOpcode();
- if(Opc == Instruction::SExt || Opc == Instruction::ZExt){
+ if (Opc == Instruction::SExt || Opc == Instruction::ZExt) {
ExtExists = true;
}
/* TODO check if something can be done with signed compares
@@ -7411,11 +7411,11 @@ bool CodeGenPrepare::optimizeSwitchType(SwitchInst *SI) {
}
}*/
}
- // Extension exists but has smaller type we need to widen it to
+ // Extension exists but has smaller type we need to widen it to
// the preferred switch type
- if(ExtExists){
- Cond->mutateType(NewType);
- }else{
+ if (ExtExists) {
+ Cond->mutateType(NewType);
+ } else {
auto *ExtInst = CastInst::Create(ExtType, Cond, NewType);
ExtInst->insertBefore(SI);
ExtInst->setDebugLoc(SI->getDebugLoc());
``````````
</details>
https://github.com/llvm/llvm-project/pull/83322
More information about the llvm-commits
mailing list