mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	YulOpt: Remove empty cases
This commit is contained in:
		
							parent
							
								
									be52aa3181
								
							
						
					
					
						commit
						21322dae29
					
				| @ -5,6 +5,9 @@ Language Features: | |||||||
| 
 | 
 | ||||||
| Compiler Features: | Compiler Features: | ||||||
|  * SMTChecker: Support one-dimensional arrays. |  * SMTChecker: Support one-dimensional arrays. | ||||||
|  |  * Yul Optimizer: Add rule to remove empty default switch cases | ||||||
|  |  * Yul Optimizer: Add rule to remove empty cases if no default exists | ||||||
|  |  * Yul Optimizer: Add rule to replace a switch with no cases with pop(expression) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| Bugfixes: | Bugfixes: | ||||||
|  | |||||||
| @ -28,6 +28,9 @@ namespace yul | |||||||
|  * - replace if with empty body with pop(condition) |  * - replace if with empty body with pop(condition) | ||||||
|  * - replace if with true condition with its body |  * - replace if with true condition with its body | ||||||
|  * - remove if with false condition |  * - remove if with false condition | ||||||
|  |  * - remove empty default switch case | ||||||
|  |  * - remove empty switch case if no default case exists | ||||||
|  |  * - replace switch with no cases with pop(expression) | ||||||
|  * - turn switch with single case into if |  * - turn switch with single case into if | ||||||
|  * - replace switch with only default case with pop(expression) and body |  * - replace switch with only default case with pop(expression) and body | ||||||
|  * - replace switch with const expr with matching case body |  * - replace switch with const expr with matching case body | ||||||
| @ -49,6 +52,7 @@ private: | |||||||
| 	bool expressionAlwaysTrue(Expression const& _expression); | 	bool expressionAlwaysTrue(Expression const& _expression); | ||||||
| 	bool expressionAlwaysFalse(Expression const& _expression); | 	bool expressionAlwaysFalse(Expression const& _expression); | ||||||
| 	boost::optional<dev::u256> hasLiteralValue(Expression const& _expression) const; | 	boost::optional<dev::u256> hasLiteralValue(Expression const& _expression) const; | ||||||
|  | 	boost::optional<std::vector<Statement>> reduceNoCaseSwitch(Switch& _switchStmt) const; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -0,0 +1,19 @@ | |||||||
|  | { | ||||||
|  | 	let y := 200 | ||||||
|  | 	switch add(y, 4) | ||||||
|  | 	case 0 { } | ||||||
|  | 	case 1 { } | ||||||
|  | 	default { } | ||||||
|  | 
 | ||||||
|  | 	switch 4 | ||||||
|  | 	case 0 { } | ||||||
|  | 	case 1 { } | ||||||
|  | 	default { } | ||||||
|  | } | ||||||
|  | // ---- | ||||||
|  | // structuralSimplifier | ||||||
|  | // { | ||||||
|  | //     let y := 200 | ||||||
|  | //     pop(add(y, 4)) | ||||||
|  | //     pop(4) | ||||||
|  | // } | ||||||
| @ -8,8 +8,8 @@ | |||||||
| // structuralSimplifier | // structuralSimplifier | ||||||
| // { | // { | ||||||
| //     let y := 200 | //     let y := 200 | ||||||
| //     switch y | //     if eq(1, y) | ||||||
| //     case 1 { | //     { | ||||||
| //         y := 9 | //         y := 9 | ||||||
| //     } | //     } | ||||||
| // } | // } | ||||||
|  | |||||||
| @ -9,8 +9,8 @@ | |||||||
| // structuralSimplifier | // structuralSimplifier | ||||||
| // { | // { | ||||||
| //     let y := 200 | //     let y := 200 | ||||||
| //     switch y | //     if eq(1, y) | ||||||
| //     case 1 { | //     { | ||||||
| //         y := 9 | //         y := 9 | ||||||
| //     } | //     } | ||||||
| // } | // } | ||||||
|  | |||||||
| @ -8,8 +8,8 @@ | |||||||
| // structuralSimplifier | // structuralSimplifier | ||||||
| // { | // { | ||||||
| //     let y := 200 | //     let y := 200 | ||||||
| //     switch y | //     if eq(1, y) | ||||||
| //     case 1 { | //     { | ||||||
| //         y := 9 | //         y := 9 | ||||||
| //     } | //     } | ||||||
| // } | // } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user