Call unbounded broadcast only when necessary.
Call unbounded broadcast only when necessary.

The scale of improvement is more apparent with shapes that have multiple unbounded sizes. Here's a before & after HLO for `add(f32[1,?,2,?,<=2,?,?], f32[?,1,?,2,?,<=2,?])` where implicit broadcasting is not necessary:

Before:
```
HloModule UnboundedBinaryOpTest_0.35, entry_computation_layout={(f32[1,?,2,?,<=2,?,?]{6,5,4,3,2,1,0}, f32[?,1,?,2,?,<=2,?]{6,5,4,3,2,1,0})->f32[?,?,2,2,<=2,<=2,?]{6,5,4,3,2,1,0}}

ENTRY %UnboundedBinaryOpTest_0.35 (lhs.1: f32[1,?,2,?,<=2,?,?], rhs.2: f32[?,1,?,2,?,<=2,?]) -> f32[?,?,2,2,<=2,<=2,?] {
  %constant.3 = s32[1]{0} constant({1})
  %constant.16 = s32[1]{0} constant({1})
  %lhs.1 = f32[1,?,2,?,<=2,?,?]{6,5,4,3,2,1,0} parameter(0)
  %constant.4 = s32[1]{0} constant({1})
  %get-dimension-size.5 = s32[] get-dimension-size(f32[1,?,2,?,<=2,?,?]{6,5,4,3,2,1,0} %lhs.1), dimensions={1}
  %reshape.6 = s32[1]{0} reshape(s32[] %get-dimension-size.5)
  %constant.7 = s32[1]{0} constant({2})
  %get-dimension-size.8 = s32[] get-dimension-size(f32[1,?,2,?,<=2,?,?]{6,5,4,3,2,1,0} %lhs.1), dimensions={3}
  %reshape.9 = s32[1]{0} reshape(s32[] %get-dimension-size.8)
  %get-dimension-size.10 = s32[] get-dimension-size(f32[1,?,2,?,<=2,?,?]{6,5,4,3,2,1,0} %lhs.1), dimensions={4}
  %reshape.11 = s32[1]{0} reshape(s32[] %get-dimension-size.10)
  %get-dimension-size.12 = s32[] get-dimension-size(f32[1,?,2,?,<=2,?,?]{6,5,4,3,2,1,0} %lhs.1), dimensions={5}
  %reshape.13 = s32[1]{0} reshape(s32[] %get-dimension-size.12)
  %get-dimension-size.14 = s32[] get-dimension-size(f32[1,?,2,?,<=2,?,?]{6,5,4,3,2,1,0} %lhs.1), dimensions={6}
  %reshape.15 = s32[1]{0} reshape(s32[] %get-dimension-size.14)
  %concatenate.29 = s32[7]{0} concatenate(s32[1]{0} %constant.4, s32[1]{0} %reshape.6, s32[1]{0} %constant.7, s32[1]{0} %reshape.9, s32[1]{0} %reshape.11, /*index=5*/s32[1]{0} %reshape.13, s32[1]{0} %reshape.15), dimensions={0}
  %rhs.2 = f32[?,1,?,2,?,<=2,?]{6,5,4,3,2,1,0} parameter(1)
  %get-dimension-size.17 = s32[] get-dimension-size(f32[?,1,?,2,?,<=2,?]{6,5,4,3,2,1,0} %rhs.2), dimensions={0}
  %reshape.18 = s32[1]{0} reshape(s32[] %get-dimension-size.17)
  %constant.19 = s32[1]{0} constant({1})
  %get-dimension-size.20 = s32[] get-dimension-size(f32[?,1,?,2,?,<=2,?]{6,5,4,3,2,1,0} %rhs.2), dimensions={2}
  %reshape.21 = s32[1]{0} reshape(s32[] %get-dimension-size.20)
  %constant.22 = s32[1]{0} constant({2})
  %get-dimension-size.23 = s32[] get-dimension-size(f32[?,1,?,2,?,<=2,?]{6,5,4,3,2,1,0} %rhs.2), dimensions={4}
  %reshape.24 = s32[1]{0} reshape(s32[] %get-dimension-size.23)
  %get-dimension-size.25 = s32[] get-dimension-size(f32[?,1,?,2,?,<=2,?]{6,5,4,3,2,1,0} %rhs.2), dimensions={5}
  %reshape.26 = s32[1]{0} reshape(s32[] %get-dimension-size.25)
  %get-dimension-size.27 = s32[] get-dimension-size(f32[?,1,?,2,?,<=2,?]{6,5,4,3,2,1,0} %rhs.2), dimensions={6}
  %reshape.28 = s32[1]{0} reshape(s32[] %get-dimension-size.27)
  %concatenate.30 = s32[7]{0} concatenate(s32[1]{0} %reshape.18, s32[1]{0} %constant.19, s32[1]{0} %reshape.21, s32[1]{0} %constant.22, s32[1]{0} %reshape.24, /*index=5*/s32[1]{0} %reshape.26, s32[1]{0} %reshape.28), dimensions={0}
  %maximum.31 = s32[7]{0} maximum(s32[7]{0} %concatenate.29, s32[7]{0} %concatenate.30)
  %custom-call.32 = f32[?,?,2,2,<=2,<=2,?]{6,5,4,3,2,1,0} custom-call(f32[1,?,2,?,<=2,?,?]{6,5,4,3,2,1,0} %lhs.1, s32[7]{0} %maximum.31), custom_call_target="mhlo.dynamic_broadcast_in_dim", backend_config={broadcast_dimensions=[0,1,2,3,4,5,6]}
  %custom-call.33 = f32[?,?,2,2,<=2,<=2,?]{6,5,4,3,2,1,0} custom-call(f32[?,1,?,2,?,<=2,?]{6,5,4,3,2,1,0} %rhs.2, s32[7]{0} %maximum.31), custom_call_target="mhlo.dynamic_broadcast_in_dim", backend_config={broadcast_dimensions=[0,1,2,3,4,5,6]}
  ROOT %add.34 = f32[?,?,2,2,<=2,<=2,?]{6,5,4,3,2,1,0} add(f32[?,?,2,2,<=2,<=2,?]{6,5,4,3,2,1,0} %custom-call.32, f32[?,?,2,2,<=2,<=2,?]{6,5,4,3,2,1,0} %custom-call.33)
}
```

After:
```
HloModule UnboundedBinaryOpTest_0.4, entry_computation_layout={(f32[1,?,2,?,<=2,?,?]{6,5,4,3,2,1,0}, f32[?,1,?,2,?,<=2,?]{6,5,4,3,2,1,0})->f32[?,?,2,2,<=2,<=2,?]{6,5,4,3,2,1,0}}

ENTRY %UnboundedBinaryOpTest_0.4 (lhs.1: f32[1,?,2,?,<=2,?,?], rhs.2: f32[?,1,?,2,?,<=2,?]) -> f32[?,?,2,2,<=2,<=2,?] {
  %lhs.1 = f32[1,?,2,?,<=2,?,?]{6,5,4,3,2,1,0} parameter(0)
  %rhs.2 = f32[?,1,?,2,?,<=2,?]{6,5,4,3,2,1,0} parameter(1)
  ROOT %add.3 = f32[?,?,2,2,<=2,<=2,?]{6,5,4,3,2,1,0} add(f32[1,?,2,?,<=2,?,?]{6,5,4,3,2,1,0} %lhs.1, f32[?,1,?,2,?,<=2,?]{6,5,4,3,2,1,0} %rhs.2)
}
```
