MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / IsAllInt1

Function IsAllInt1

source/opt/folding_rules.cpp:3800–3809  ·  view source on GitHub ↗

Returns true if all elements in |c| are 1.

Source from the content-addressed store, hash-verified

3798
3799// Returns true if all elements in |c| are 1.
3800bool 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).
3812FoldingRule RedundantSUDiv() {

Callers 2

RedundantSUDivFunction · 0.85
RedundantSUModFunction · 0.85

Calls 3

GetSignExtendedValueMethod · 0.80
AsCompositeConstantMethod · 0.45
AsIntConstantMethod · 0.45

Tested by

no test coverage detected