@@ -5054,7 +5054,57 @@ INSTANTIATE_TEST_SUITE_P(IntegerRedundantFoldingTest, GeneralInstructionFoldingT
5054
5054
"OpReturn\n" +
5055
5055
"OpFunctionEnd",
5056
5056
2, 0),
5057
- // Test case 2: Fold n + 0
5057
+ // Test case 2: Fold n | 0
5058
+ InstructionFoldingCase<uint32_t>(
5059
+ Header() + "%main = OpFunction %void None %void_func\n" +
5060
+ "%main_lab = OpLabel\n" +
5061
+ "%n = OpVariable %_ptr_uint Function\n" +
5062
+ "%3 = OpLoad %uint %n\n" +
5063
+ "%2 = OpBitwiseOr %uint %3 %uint_0\n" +
5064
+ "OpReturn\n" +
5065
+ "OpFunctionEnd",
5066
+ 2, 3),
5067
+ // Test case 3: Fold n ^ 0
5068
+ InstructionFoldingCase<uint32_t>(
5069
+ Header() + "%main = OpFunction %void None %void_func\n" +
5070
+ "%main_lab = OpLabel\n" +
5071
+ "%n = OpVariable %_ptr_uint Function\n" +
5072
+ "%3 = OpLoad %uint %n\n" +
5073
+ "%2 = OpBitwiseXor %uint %3 %uint_0\n" +
5074
+ "OpReturn\n" +
5075
+ "OpFunctionEnd",
5076
+ 2, 3),
5077
+ // Test case 4: Fold n >> 0
5078
+ InstructionFoldingCase<uint32_t>(
5079
+ Header() + "%main = OpFunction %void None %void_func\n" +
5080
+ "%main_lab = OpLabel\n" +
5081
+ "%n = OpVariable %_ptr_uint Function\n" +
5082
+ "%3 = OpLoad %uint %n\n" +
5083
+ "%2 = OpShiftRightLogical %uint %3 %uint_0\n" +
5084
+ "OpReturn\n" +
5085
+ "OpFunctionEnd",
5086
+ 2, 3),
5087
+ // Test case 5: Fold n >> 0
5088
+ InstructionFoldingCase<uint32_t>(
5089
+ Header() + "%main = OpFunction %void None %void_func\n" +
5090
+ "%main_lab = OpLabel\n" +
5091
+ "%n = OpVariable %_ptr_uint Function\n" +
5092
+ "%3 = OpLoad %uint %n\n" +
5093
+ "%2 = OpShiftRightArithmetic %uint %3 %uint_0\n" +
5094
+ "OpReturn\n" +
5095
+ "OpFunctionEnd",
5096
+ 2, 3),
5097
+ // Test case 6: Fold n << 0
5098
+ InstructionFoldingCase<uint32_t>(
5099
+ Header() + "%main = OpFunction %void None %void_func\n" +
5100
+ "%main_lab = OpLabel\n" +
5101
+ "%n = OpVariable %_ptr_uint Function\n" +
5102
+ "%3 = OpLoad %uint %n\n" +
5103
+ "%2 = OpShiftLeftLogical %uint %3 %uint_0\n" +
5104
+ "OpReturn\n" +
5105
+ "OpFunctionEnd",
5106
+ 2, 3),
5107
+ // Test case 7: Fold n + 0
5058
5108
InstructionFoldingCase<uint32_t>(
5059
5109
Header() + "%main = OpFunction %void None %void_func\n" +
5060
5110
"%main_lab = OpLabel\n" +
@@ -5064,7 +5114,37 @@ INSTANTIATE_TEST_SUITE_P(IntegerRedundantFoldingTest, GeneralInstructionFoldingT
5064
5114
"OpReturn\n" +
5065
5115
"OpFunctionEnd",
5066
5116
2, 3),
5067
- // Test case 3: Fold 0 + n
5117
+ // Test case 8: Fold n - 0
5118
+ InstructionFoldingCase<uint32_t>(
5119
+ Header() + "%main = OpFunction %void None %void_func\n" +
5120
+ "%main_lab = OpLabel\n" +
5121
+ "%n = OpVariable %_ptr_uint Function\n" +
5122
+ "%3 = OpLoad %uint %n\n" +
5123
+ "%2 = OpISub %uint %3 %uint_0\n" +
5124
+ "OpReturn\n" +
5125
+ "OpFunctionEnd",
5126
+ 2, 3),
5127
+ // Test case 9: Fold 0 | n
5128
+ InstructionFoldingCase<uint32_t>(
5129
+ Header() + "%main = OpFunction %void None %void_func\n" +
5130
+ "%main_lab = OpLabel\n" +
5131
+ "%n = OpVariable %_ptr_uint Function\n" +
5132
+ "%3 = OpLoad %uint %n\n" +
5133
+ "%2 = OpBitwiseOr %uint %uint_0 %3\n" +
5134
+ "OpReturn\n" +
5135
+ "OpFunctionEnd",
5136
+ 2, 3),
5137
+ // Test case 10: Fold 0 ^ n
5138
+ InstructionFoldingCase<uint32_t>(
5139
+ Header() + "%main = OpFunction %void None %void_func\n" +
5140
+ "%main_lab = OpLabel\n" +
5141
+ "%n = OpVariable %_ptr_uint Function\n" +
5142
+ "%3 = OpLoad %uint %n\n" +
5143
+ "%2 = OpBitwiseXor %uint %uint_0 %3\n" +
5144
+ "OpReturn\n" +
5145
+ "OpFunctionEnd",
5146
+ 2, 3),
5147
+ // Test case 11: Fold 0 + n
5068
5148
InstructionFoldingCase<uint32_t>(
5069
5149
Header() + "%main = OpFunction %void None %void_func\n" +
5070
5150
"%main_lab = OpLabel\n" +
@@ -5074,7 +5154,7 @@ INSTANTIATE_TEST_SUITE_P(IntegerRedundantFoldingTest, GeneralInstructionFoldingT
5074
5154
"OpReturn\n" +
5075
5155
"OpFunctionEnd",
5076
5156
2, 3),
5077
- // Test case 4 : Don't fold n + (1,0)
5157
+ // Test case 12 : Don't fold n + (1,0)
5078
5158
InstructionFoldingCase<uint32_t>(
5079
5159
Header() + "%main = OpFunction %void None %void_func\n" +
5080
5160
"%main_lab = OpLabel\n" +
@@ -5084,7 +5164,7 @@ INSTANTIATE_TEST_SUITE_P(IntegerRedundantFoldingTest, GeneralInstructionFoldingT
5084
5164
"OpReturn\n" +
5085
5165
"OpFunctionEnd",
5086
5166
2, 0),
5087
- // Test case 5 : Don't fold (1,0) + n
5167
+ // Test case 13 : Don't fold (1,0) + n
5088
5168
InstructionFoldingCase<uint32_t>(
5089
5169
Header() + "%main = OpFunction %void None %void_func\n" +
5090
5170
"%main_lab = OpLabel\n" +
@@ -5094,7 +5174,7 @@ INSTANTIATE_TEST_SUITE_P(IntegerRedundantFoldingTest, GeneralInstructionFoldingT
5094
5174
"OpReturn\n" +
5095
5175
"OpFunctionEnd",
5096
5176
2, 0),
5097
- // Test case 6 : Fold n + (0,0)
5177
+ // Test case 14 : Fold n + (0,0)
5098
5178
InstructionFoldingCase<uint32_t>(
5099
5179
Header() + "%main = OpFunction %void None %void_func\n" +
5100
5180
"%main_lab = OpLabel\n" +
@@ -5104,7 +5184,7 @@ INSTANTIATE_TEST_SUITE_P(IntegerRedundantFoldingTest, GeneralInstructionFoldingT
5104
5184
"OpReturn\n" +
5105
5185
"OpFunctionEnd",
5106
5186
2, 3),
5107
- // Test case 7 : Fold (0,0) + n
5187
+ // Test case 15 : Fold (0,0) + n
5108
5188
InstructionFoldingCase<uint32_t>(
5109
5189
Header() + "%main = OpFunction %void None %void_func\n" +
5110
5190
"%main_lab = OpLabel\n" +
@@ -5114,7 +5194,27 @@ INSTANTIATE_TEST_SUITE_P(IntegerRedundantFoldingTest, GeneralInstructionFoldingT
5114
5194
"OpReturn\n" +
5115
5195
"OpFunctionEnd",
5116
5196
2, 3),
5117
- // Test case 8: Don't fold because of undefined value. Using 4294967295
5197
+ // Test case 16: Fold n | (0,0)
5198
+ InstructionFoldingCase<uint32_t>(
5199
+ Header() + "%main = OpFunction %void None %void_func\n" +
5200
+ "%main_lab = OpLabel\n" +
5201
+ "%n = OpVariable %_ptr_v2int Function\n" +
5202
+ "%3 = OpLoad %v2int %n\n" +
5203
+ "%2 = OpBitwiseOr %v2int %3 %v2int_0_0\n" +
5204
+ "OpReturn\n" +
5205
+ "OpFunctionEnd",
5206
+ 2, 3),
5207
+ // Test case 17: Fold (0,0) | n
5208
+ InstructionFoldingCase<uint32_t>(
5209
+ Header() + "%main = OpFunction %void None %void_func\n" +
5210
+ "%main_lab = OpLabel\n" +
5211
+ "%n = OpVariable %_ptr_v2int Function\n" +
5212
+ "%3 = OpLoad %v2int %n\n" +
5213
+ "%2 = OpBitwiseOr %v2int %v2int_0_0 %3\n" +
5214
+ "OpReturn\n" +
5215
+ "OpFunctionEnd",
5216
+ 2, 3),
5217
+ // Test case 18: Don't fold because of undefined value. Using 4294967295
5118
5218
// means that entry is undefined. We do not expect it to ever happen, so
5119
5219
// not worth folding.
5120
5220
InstructionFoldingCase<uint32_t>(
@@ -5126,7 +5226,7 @@ INSTANTIATE_TEST_SUITE_P(IntegerRedundantFoldingTest, GeneralInstructionFoldingT
5126
5226
"OpReturn\n" +
5127
5227
"OpFunctionEnd",
5128
5228
2, 0),
5129
- // Test case 9 : Don't fold because of undefined value. Using 4294967295
5229
+ // Test case 19 : Don't fold because of undefined value. Using 4294967295
5130
5230
// means that entry is undefined. We do not expect it to ever happen, so
5131
5231
// not worth folding.
5132
5232
InstructionFoldingCase<uint32_t>(
0 commit comments