Returns true if all elements in |c| are 1.
| 3798 | |
| 3799 | // Returns true if all elements in |c| are 1. |
| 3800 | bool IsAllInt1(const analysis::Constant* c) { |
| 3801 | if (auto composite = c->AsCompositeConstant()) { |
| 3802 | auto& components = composite->GetComponents(); |
| 3803 | return std::all_of(std::begin(components), std::end(components), IsAllInt1); |
| 3804 | } else if (c->AsIntConstant()) { |
| 3805 | return c->GetSignExtendedValue() == 1; |
| 3806 | } |
| 3807 | |
| 3808 | return false; |
| 3809 | } |
| 3810 | |
| 3811 | // This rule handles divisions by 1 or vector 1 (a / 1 => a). |
| 3812 | FoldingRule RedundantSUDiv() { |
no test coverage detected