Commit b19edc0
Replace explicit GTF_UNSIGNED flag operations with GenTree helper methods (#123265)
## Description
Refactored JIT codebase to use existing GenTree helper methods
(`IsUnsigned()`, `SetUnsigned()`, `ClearUnsigned()`) instead of direct
GTF_UNSIGNED flag manipulation.
## Changes
**Replaced 55 explicit flag operations across 22 files:**
- `gtFlags |= GTF_UNSIGNED` → `SetUnsigned()` (13 occurrences)
- `gtFlags &= ~GTF_UNSIGNED` → `ClearUnsigned()` (3 occurrences)
- `(gtFlags & GTF_UNSIGNED)` → `IsUnsigned()` (39 occurrences)
**Moved SetUnsigned/ClearUnsigned to gentree.cpp:**
- Implementations moved from inline methods in gentree.h to gentree.cpp
- gentree.h now contains only method declarations for cleaner separation
- Added debug assertions that print the node operator type on failure
for easier debugging
- Assertions validate that GTF_UNSIGNED is only set on appropriate node
types:
- Arithmetic operations: GT_ADD, GT_SUB
- Casts: GT_CAST
- All comparison operators (using `OperIsCompare()` helper): GT_EQ,
GT_NE, GT_LE, GT_LT, GT_GT, GT_GE, GT_TEST_EQ, GT_TEST_NE, and on XARCH
also GT_BITTEST_EQ, GT_BITTEST_NE
- Multiply operations (via `OperIsMul()` helper): GT_MUL, GT_MULHI,
GT_MUL_LONG
## Testing
- CoreCLR builds successfully
- Enhanced assertions provide helpful diagnostic output during
development
- No functional changes
<!-- START COPILOT CODING AGENT SUFFIX -->
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
> # A small clenaup task in JIT codebase around GTF_UNSIGNED
> in `src/coreclr/jit/*` replace explicit usages of GTF_UNSIGNED over
tree objects (e.g. `tmp->gtFlags |= GTF_UNSIGNED;`) with the following
methods on GenTree:
>
> ```
> bool GenTree::IsUnsigned() const
> void GenTree::SetUnsigned()
> void GenTree::ClearUnsigned()
> ```
>
> Make sure code compiles and runtime tests pass.
</details>
<!-- START COPILOT CODING AGENT TIPS -->
---
✨ Let Copilot coding agent [set things up for
you](https://github.com/dotnet/runtime/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
Co-authored-by: Egor Bogatov <egorbo@gmail.com>1 parent 8fafcb3 commit b19edc0
23 files changed
Lines changed: 57 additions & 53 deletions
File tree
- src/coreclr/jit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1429 | 1429 | | |
1430 | 1430 | | |
1431 | 1431 | | |
1432 | | - | |
| 1432 | + | |
1433 | 1433 | | |
1434 | 1434 | | |
1435 | 1435 | | |
| |||
1520 | 1520 | | |
1521 | 1521 | | |
1522 | 1522 | | |
1523 | | - | |
| 1523 | + | |
1524 | 1524 | | |
1525 | 1525 | | |
1526 | 1526 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2431 | 2431 | | |
2432 | 2432 | | |
2433 | 2433 | | |
2434 | | - | |
| 2434 | + | |
2435 | 2435 | | |
2436 | 2436 | | |
2437 | 2437 | | |
| |||
4387 | 4387 | | |
4388 | 4388 | | |
4389 | 4389 | | |
4390 | | - | |
| 4390 | + | |
4391 | 4391 | | |
4392 | 4392 | | |
4393 | 4393 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1730 | 1730 | | |
1731 | 1731 | | |
1732 | 1732 | | |
1733 | | - | |
| 1733 | + | |
1734 | 1734 | | |
1735 | 1735 | | |
1736 | 1736 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1065 | 1065 | | |
1066 | 1066 | | |
1067 | 1067 | | |
1068 | | - | |
| 1068 | + | |
1069 | 1069 | | |
1070 | 1070 | | |
1071 | 1071 | | |
| |||
2874 | 2874 | | |
2875 | 2875 | | |
2876 | 2876 | | |
2877 | | - | |
| 2877 | + | |
2878 | 2878 | | |
2879 | 2879 | | |
2880 | 2880 | | |
| |||
3270 | 3270 | | |
3271 | 3271 | | |
3272 | 3272 | | |
3273 | | - | |
| 3273 | + | |
3274 | 3274 | | |
3275 | 3275 | | |
3276 | 3276 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1053 | 1053 | | |
1054 | 1054 | | |
1055 | 1055 | | |
1056 | | - | |
| 1056 | + | |
1057 | 1057 | | |
1058 | 1058 | | |
1059 | 1059 | | |
| |||
2941 | 2941 | | |
2942 | 2942 | | |
2943 | 2943 | | |
2944 | | - | |
| 2944 | + | |
2945 | 2945 | | |
2946 | 2946 | | |
2947 | 2947 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1125 | 1125 | | |
1126 | 1126 | | |
1127 | 1127 | | |
1128 | | - | |
| 1128 | + | |
1129 | 1129 | | |
1130 | 1130 | | |
1131 | 1131 | | |
| |||
6657 | 6657 | | |
6658 | 6658 | | |
6659 | 6659 | | |
6660 | | - | |
| 6660 | + | |
6661 | 6661 | | |
6662 | 6662 | | |
6663 | 6663 | | |
| |||
6819 | 6819 | | |
6820 | 6820 | | |
6821 | 6821 | | |
6822 | | - | |
| 6822 | + | |
6823 | 6823 | | |
6824 | 6824 | | |
6825 | 6825 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9996 | 9996 | | |
9997 | 9997 | | |
9998 | 9998 | | |
9999 | | - | |
| 9999 | + | |
10000 | 10000 | | |
10001 | 10001 | | |
10002 | 10002 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1080 | 1080 | | |
1081 | 1081 | | |
1082 | 1082 | | |
1083 | | - | |
| 1083 | + | |
1084 | 1084 | | |
1085 | | - | |
| 1085 | + | |
1086 | 1086 | | |
1087 | 1087 | | |
1088 | 1088 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8178 | 8178 | | |
8179 | 8179 | | |
8180 | 8180 | | |
8181 | | - | |
| 8181 | + | |
8182 | 8182 | | |
8183 | 8183 | | |
8184 | 8184 | | |
| |||
8214 | 8214 | | |
8215 | 8215 | | |
8216 | 8216 | | |
8217 | | - | |
| 8217 | + | |
8218 | 8218 | | |
8219 | 8219 | | |
8220 | 8220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14784 | 14784 | | |
14785 | 14785 | | |
14786 | 14786 | | |
14787 | | - | |
| 14787 | + | |
14788 | 14788 | | |
14789 | 14789 | | |
14790 | 14790 | | |
| |||
0 commit comments