if (a > b) { p = a; } else { p = 2; } return x.length / p; } 11 MOTIVATING EXAMPLE Fastpath Slowpath Expensive operation p=2 in the false branch Strength Reduction if we know p == 2 and x.length >= 0 x.length / 2 x.length >> 1
if (a > b) { p = a; } else { p = 2; } return x.length / p; } 12 MOTIVATING EXAMPLE Fastpath Slowpath Expensive operation p=2 in the false branch Merge is an optimization boundary Strength Reduction if we know p == 2 and x.length >= 0 x.length / 2 x.length >> 1
if (a > b) { p = a; } else { p = 2; } return x.length / p; } 13 MOTIVATING EXAMPLE Fastpath Slowpath Expensive operation p=2 in the false branch Merge is an optimization boundary Only allowed if isPowerOf2(a) == true Strength Reduction if we know p == 2 and x.length >= 0 x.length / 2 x.length >> 1
if (a > b) { p = a; } else { p = 2; } return x.length / p; } 14 MOTIVATING EXAMPLE Fastpath Slowpath Expensive operation p=2 in the false branch Merge is an optimization boundary Solution Duplication Strength Reduction if we know p == 2 and x.length >= 0 x.length / 2 x.length >> 1
duplications will increase peak performance P2 We need to know which optimizations are enabled by a certain duplication P3 Finding those optimization opportunities after duplication is compile time intensive, therefore, we need to find a way to perform this kind of analysis in acceptable time in a JIT compiler
every possible duplication Sort by • Benefit • Cost • Probability Duplicate & Optimize Conditional Elimination PEA & Scalar Replacement Strength Reduction Duplicate Optimize Initial IR Optimization Potential For each Duplication Beneficial Duplications Optimized IR Decide if duplication is beneficial
every possible duplication Sort by • Benefit • Cost • Probability Duplicate & Optimize Conditional Elimination PEA & Scalar Replacement Strength Reduction Duplicate Optimize Initial IR Optimization Potential For each Duplication Beneficial Duplications Optimized IR Decide if duplication is beneficial
every possible duplication Sort by • Benefit • Cost • Probability Duplicate & Optimize Conditional Elimination PEA & Scalar Replacement Strength Reduction Duplicate Optimize Initial IR Optimization Potential For each Duplication Beneficial Duplications Optimized IR Decide if duplication is beneficial
every possible duplication Sort by • Benefit • Cost • Probability Duplicate & Optimize Conditional Elimination PEA & Scalar Replacement Strength Reduction Duplicate Optimize Initial IR Optimization Potential For each Duplication Beneficial Duplications Optimized IR Decide if duplication is beneficial
every possible duplication Sort by • Benefit • Cost • Probability Duplicate & Optimize Simulation Tier Trade-off Tier Optimization Tier Conditional Elimination PEA & Scalar Replacement Strength Reduction Duplicate Optimize Initial IR Optimization Potential For each Duplication Beneficial Duplications Optimized IR Decide if duplication is beneficial