Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
runtime
提交
933dbb15
R
runtime
项目概览
dotNET Platform
/
runtime
大约 1 年 前同步成功
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
runtime
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
933dbb15
编写于
6月 10, 2022
作者:
J
Jakob Botsch Nielsen
提交者:
GitHub
6月 10, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid discarding upper bits when folding GT_SWITCH (#69986)
上级
b22fcf4e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
142 addition
and
21 deletion
+142
-21
src/coreclr/jit/fgopt.cpp
src/coreclr/jit/fgopt.cpp
+6
-1
src/coreclr/jit/morph.cpp
src/coreclr/jit/morph.cpp
+14
-20
src/tests/JIT/Regression/JitBlue/Runtime_68568/Runtime_68568.il
...sts/JIT/Regression/JitBlue/Runtime_68568/Runtime_68568.il
+107
-0
src/tests/JIT/Regression/JitBlue/Runtime_68568/Runtime_68568.ilproj
...JIT/Regression/JitBlue/Runtime_68568/Runtime_68568.ilproj
+12
-0
src/tests/issues.targets
src/tests/issues.targets
+3
-0
未找到文件。
src/coreclr/jit/fgopt.cpp
浏览文件 @
933dbb15
...
...
@@ -3221,8 +3221,10 @@ bool Compiler::fgOptimizeSwitchBranches(BasicBlock* block)
if
(
verbose
)
{
printf
(
"
\n
Converting a switch ("
FMT_BB
") with only one significant clause besides a default target to a "
"conditional branch
\n
"
,
"conditional branch
. Before:
\n
"
,
block
->
bbNum
);
gtDispTree
(
switchTree
);
}
#endif // DEBUG
...
...
@@ -3247,6 +3249,9 @@ bool Compiler::fgOptimizeSwitchBranches(BasicBlock* block)
block
->
bbJumpDest
=
block
->
bbJumpSwt
->
bbsDstTab
[
0
];
block
->
bbJumpKind
=
BBJ_COND
;
JITDUMP
(
"After:
\n
"
);
DISPNODE
(
switchTree
);
return
true
;
}
return
returnvalue
;
...
...
src/coreclr/jit/morph.cpp
浏览文件 @
933dbb15
...
...
@@ -14922,18 +14922,16 @@ Compiler::FoldResult Compiler::fgFoldConditional(BasicBlock* block)
noway_assert(lastStmt->GetRootNode()->gtOper == GT_SWITCH);
/
* Did we fold the conditional */
/
/ Did we fold the conditional
noway_assert(lastStmt->GetRootNode()->AsOp()->gtOp1);
GenTree* condTree;
condTree = lastStmt->GetRootNode()->AsOp()->gtOp1;
GenTree* cond;
cond = condTree->gtEffectiveVal(true);
GenTree* condTree = lastStmt->GetRootNode()->AsOp()->gtOp1;
GenTree* cond = condTree->gtEffectiveVal(true);
if (cond->OperIsConst())
{
/
*
Yupee - we folded the conditional!
* Remove the conditional statement */
/
/
Yupee - we folded the conditional!
// Remove the conditional statement
noway_assert(cond->gtOper == GT_CNS_INT);
...
...
@@ -14951,17 +14949,13 @@ Compiler::FoldResult Compiler::fgFoldConditional(BasicBlock* block)
result = FoldResult::FOLD_REMOVED_LAST_STMT;
}
/
* modify the flow graph */
/
/ modify the flow graph
/* Find the actual jump target */
unsigned switchVal;
switchVal = (unsigned)cond->AsIntCon()->gtIconVal;
unsigned jumpCnt;
jumpCnt = block->bbJumpSwt->bbsCount;
BasicBlock** jumpTab;
jumpTab = block->bbJumpSwt->bbsDstTab;
bool foundVal;
foundVal = false;
// Find the actual jump target
size_t switchVal = (size_t)cond->AsIntCon()->gtIconVal;
unsigned jumpCnt = block->bbJumpSwt->bbsCount;
BasicBlock** jumpTab = block->bbJumpSwt->bbsDstTab;
bool foundVal = false;
for (unsigned val = 0; val < jumpCnt; val++, jumpTab++)
{
...
...
@@ -14976,20 +14970,20 @@ Compiler::FoldResult Compiler::fgFoldConditional(BasicBlock* block)
{
if (curJump != block->bbNext)
{
/
* transform the basic block into a BBJ_ALWAYS */
/
/ transform the basic block into a BBJ_ALWAYS
block->bbJumpKind = BBJ_ALWAYS;
block->bbJumpDest = curJump;
}
else
{
/
* transform the basic block into a BBJ_NONE */
/
/ transform the basic block into a BBJ_NONE
block->bbJumpKind = BBJ_NONE;
}
foundVal = true;
}
else
{
/
* Remove 'block' from the predecessor list of 'curJump' */
/
/ Remove 'block' from the predecessor list of 'curJump'
fgRemoveRefPred(curJump, block);
}
}
...
...
src/tests/JIT/Regression/JitBlue/Runtime_68568/Runtime_68568.il
0 → 100644
浏览文件 @
933dbb15
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Metadata version: v4.0.30319
.assembly extern System.Runtime
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....:
.ver 7:0:0:0
}
.assembly extern System.Console
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....:
.ver 7:0:0:0
}
.assembly playground
{
}
// =============== CLASS MEMBERS DECLARATION ===================
.class public auto ansi beforefieldinit Runtime_68568
extends [System.Runtime]System.Object
{
.method public hidebysig static int32 Main() cil managed
{
.entrypoint
// Code size 79 (0x4f)
.maxstack 2
.locals init (bool V_0)
// Code equivalent to the following, except without the
// int cast that C# adds on switch cases.
//
// switch (unchecked((nuint)0x100000000))
// {
// case 0:
// pass = sizeof(nint) == 4;
// break;
// case 1:
// pass = false;
// break;
// default:
// pass = sizeof(nint) == 8;
// break;
// }
//
// if (pass)
// {
// Console.WriteLine("PASS");
// return 100;
// }
//
// Console.WriteLine("FAIL");
// return -1;
IL_0000: ldc.i4.0
IL_0001: stloc.0
IL_0002: ldc.i8 0x100000000
IL_000b: conv.u
IL_000c: switch (
IL_0025,
IL_0031)
IL_0019: sizeof [System.Runtime]System.IntPtr
IL_001f: ldc.i4.8
IL_0020: ceq
IL_0022: stloc.0
IL_0023: br.s IL_0033
IL_0025: sizeof [System.Runtime]System.IntPtr
IL_002b: ldc.i4.4
IL_002c: ceq
IL_002e: stloc.0
IL_002f: br.s IL_0033
IL_0031: ldc.i4.0
IL_0032: stloc.0
IL_0033: ldloc.0
IL_0034: brfalse.s IL_0043
IL_0036: ldstr "PASS"
IL_003b: call void [System.Console]System.Console::WriteLine(string)
IL_0040: ldc.i4.s 100
IL_0042: ret
IL_0043: ldstr "FAIL"
IL_0048: call void [System.Console]System.Console::WriteLine(string)
IL_004d: ldc.i4.m1
IL_004e: ret
} // end of method Runtime_68568::Main
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [System.Runtime]System.Object::.ctor()
IL_0006: ret
} // end of method Runtime_68568::.ctor
} // end of class Runtime_68568
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************
src/tests/JIT/Regression/JitBlue/Runtime_68568/Runtime_68568.ilproj
0 → 100644
浏览文件 @
933dbb15
<Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).il" />
</ItemGroup>
</Project>
src/tests/issues.targets
浏览文件 @
933dbb15
...
...
@@ -2201,6 +2201,9 @@
<ExcludeList
Include=
"$(XunitTestBinBase)/JIT/Regression/JitBlue/Runtime_70259/Runtime_70259/*"
>
<Issue>
https://github.com/dotnet/runtime/issues/70279
</Issue>
</ExcludeList>
<ExcludeList
Include=
"$(XunitTestBinBase)/JIT/Regression/JitBlue/Runtime_68568/Runtime_68568/*"
>
<Issue>
Tests coreclr's handling of switches on natively sized integers
</Issue>
</ExcludeList>
</ItemGroup>
<!-- Known failures for mono runtime on Windows -->
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录