This is the purpose of all the serie of patches: inline sum and product. Patches 62..65, possibly don't deserve a patch of their own, they just make the changes in gfc_conv_intrinsic_arith easier to read. The combined diff (context, ignoring indent changes) also attached here. Patch 62: Change conditions. Patch 63: Update argument handling. Patch 64: Change loop usage. Patch 65: Change gfc_se structs initializers. Patch 66: Inline sum.