Index: llvm/test/Transforms/PhaseOrdering/reassociate-after-unroll.ll =================================================================== --- llvm/test/Transforms/PhaseOrdering/reassociate-after-unroll.ll +++ llvm/test/Transforms/PhaseOrdering/reassociate-after-unroll.ll @@ -9,101 +9,101 @@ define dso_local i64 @func(i64 %blah, i64 %limit) #0 { ; CHECK-LABEL: @func( -; CHECK-NEXT: entry: -; CHECK-NEXT: [[CMP4:%.*]] = icmp eq i64 [[LIMIT:%.*]], 0 -; CHECK-NEXT: br i1 [[CMP4]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_BODY_LR_PH:%.*]] -; CHECK: for.body.lr.ph: -; CHECK-NEXT: [[CONV:%.*]] = and i64 [[BLAH:%.*]], 4294967295 -; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[LIMIT]], -1 -; CHECK-NEXT: [[XTRAITER:%.*]] = and i64 [[LIMIT]], 7 -; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i64 [[TMP0]], 7 -; CHECK-NEXT: br i1 [[TMP1]], label [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA:%.*]], label [[FOR_BODY_LR_PH_NEW:%.*]] -; CHECK: for.body.lr.ph.new: -; CHECK-NEXT: [[UNROLL_ITER:%.*]] = sub i64 [[LIMIT]], [[XTRAITER]] -; CHECK-NEXT: br label [[FOR_BODY:%.*]] -; CHECK: for.cond.cleanup.loopexit.unr-lcssa: -; CHECK-NEXT: [[ADD_LCSSA_PH:%.*]] = phi i64 [ undef, [[FOR_BODY_LR_PH]] ], [ [[ADD_7:%.*]], [[FOR_BODY]] ] -; CHECK-NEXT: [[K_05_UNR:%.*]] = phi i64 [ 1, [[FOR_BODY_LR_PH]] ], [ [[AND:%.*]], [[FOR_BODY]] ] -; CHECK-NEXT: [[LCMP_MOD:%.*]] = icmp eq i64 [[XTRAITER]], 0 -; CHECK-NEXT: br i1 [[LCMP_MOD]], label [[FOR_COND_CLEANUP]], label [[FOR_BODY_EPIL:%.*]] -; CHECK: for.body.epil: -; CHECK-NEXT: [[G_06_EPIL:%.*]] = phi i64 [ [[ADD_EPIL:%.*]], [[FOR_BODY_EPIL]] ], [ [[ADD_LCSSA_PH]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ] -; CHECK-NEXT: [[K_05_EPIL:%.*]] = phi i64 [ [[AND_EPIL:%.*]], [[FOR_BODY_EPIL]] ], [ [[K_05_UNR]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ] -; CHECK-NEXT: [[EPIL_ITER:%.*]] = phi i64 [ [[EPIL_ITER_SUB:%.*]], [[FOR_BODY_EPIL]] ], [ [[XTRAITER]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ] -; CHECK-NEXT: [[AND_EPIL]] = and i64 [[CONV]], [[K_05_EPIL]] -; CHECK-NEXT: [[ADD_EPIL]] = add i64 [[AND_EPIL]], [[G_06_EPIL]] -; CHECK-NEXT: [[EPIL_ITER_SUB]] = add i64 [[EPIL_ITER]], -1 -; CHECK-NEXT: [[EPIL_ITER_CMP:%.*]] = icmp eq i64 [[EPIL_ITER_SUB]], 0 -; CHECK-NEXT: br i1 [[EPIL_ITER_CMP]], label [[FOR_COND_CLEANUP]], label [[FOR_BODY_EPIL]], !llvm.loop !0 -; CHECK: for.cond.cleanup: -; CHECK-NEXT: [[G_0_LCSSA:%.*]] = phi i64 [ undef, [[ENTRY:%.*]] ], [ [[ADD_LCSSA_PH]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ], [ [[ADD_EPIL]], [[FOR_BODY_EPIL]] ] -; CHECK-NEXT: ret i64 [[G_0_LCSSA]] -; CHECK: for.body: -; CHECK-NEXT: [[G_06:%.*]] = phi i64 [ undef, [[FOR_BODY_LR_PH_NEW]] ], [ [[ADD_7]], [[FOR_BODY]] ] -; CHECK-NEXT: [[K_05:%.*]] = phi i64 [ 1, [[FOR_BODY_LR_PH_NEW]] ], [ [[AND]], [[FOR_BODY]] ] -; CHECK-NEXT: [[NITER:%.*]] = phi i64 [ [[UNROLL_ITER]], [[FOR_BODY_LR_PH_NEW]] ], [ [[NITER_NSUB_7:%.*]], [[FOR_BODY]] ] -; CHECK-NEXT: [[AND]] = and i64 [[CONV]], [[K_05]] -; CHECK-NEXT: [[ADD:%.*]] = add i64 [[AND]], [[G_06]] -; CHECK-NEXT: [[ADD_1:%.*]] = add i64 [[AND]], [[ADD]] -; CHECK-NEXT: [[ADD_2:%.*]] = add i64 [[AND]], [[ADD_1]] -; CHECK-NEXT: [[ADD_3:%.*]] = add i64 [[AND]], [[ADD_2]] -; CHECK-NEXT: [[ADD_4:%.*]] = add i64 [[AND]], [[ADD_3]] -; CHECK-NEXT: [[ADD_5:%.*]] = add i64 [[AND]], [[ADD_4]] -; CHECK-NEXT: [[ADD_6:%.*]] = add i64 [[AND]], [[ADD_5]] -; CHECK-NEXT: [[ADD_7]] = add i64 [[AND]], [[ADD_6]] -; CHECK-NEXT: [[NITER_NSUB_7]] = add i64 [[NITER]], -8 -; CHECK-NEXT: [[NITER_NCMP_7:%.*]] = icmp eq i64 [[NITER_NSUB_7]], 0 -; CHECK-NEXT: br i1 [[NITER_NCMP_7]], label [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]], label [[FOR_BODY]] +; CHECK-NEXT: [[ENTRY:.*]]: +; CHECK-NEXT: %[[CMP4:.*]] = icmp eq i64 %[[LIMIT:.*]], 0 +; CHECK-NEXT: br i1 %[[CMP4]], label %[[FOR_COND_CLEANUP:.*]], label %[[FOR_BODY_LR_PH:.*]] +; CHECK: [[FOR_BODY_LR_PH]]: +; CHECK-NEXT: %[[CONV:.*]] = and i64 %[[BLAH:.*]], 4294967295 +; CHECK-NEXT: %[[TMP0:.*]] = add i64 %[[LIMIT]], -1 +; CHECK-NEXT: %[[XTRAITER:.*]] = and i64 %[[LIMIT]], 7 +; CHECK-NEXT: %[[TMP1:.*]] = icmp ult i64 %[[TMP0]], 7 +; CHECK-NEXT: br i1 %[[TMP1]], label %[[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA:.*]], label %[[FOR_BODY_LR_PH_NEW:.*]] +; CHECK: [[FOR_BODY_LR_PH_NEW]]: +; CHECK-NEXT: %[[UNROLL_ITER:.*]] = sub i64 %[[LIMIT]], %[[XTRAITER]] +; CHECK-NEXT: br label %[[FOR_BODY:.*]] +; CHECK: [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]]: +; CHECK-NEXT: %[[ADD_LCSSA_PH:.*]] = phi i64 [ undef, %[[FOR_BODY_LR_PH]] ], [ %[[ADD_7:.*]], %[[FOR_BODY]] ] +; CHECK-NEXT: %[[K_05_UNR:.*]] = phi i64 [ 1, %[[FOR_BODY_LR_PH]] ], [ %[[AND:.*]], %[[FOR_BODY]] ] +; CHECK-NEXT: %[[LCMP_MOD:.*]] = icmp eq i64 %[[XTRAITER]], 0 +; CHECK-NEXT: br i1 %[[LCMP_MOD]], label %[[FOR_COND_CLEANUP]], label %[[FOR_BODY_EPIL:.*]] +; CHECK: [[FOR_BODY_EPIL]]: +; CHECK-NEXT: %[[G_06_EPIL:.*]] = phi i64 [ %[[ADD_EPIL:.*]], %[[FOR_BODY_EPIL]] ], [ %[[ADD_LCSSA_PH]], %[[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ] +; CHECK-NEXT: %[[K_05_EPIL:.*]] = phi i64 [ %[[AND_EPIL:.*]], %[[FOR_BODY_EPIL]] ], [ %[[K_05_UNR]], %[[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ] +; CHECK-NEXT: %[[EPIL_ITER:.*]] = phi i64 [ %[[EPIL_ITER_SUB:.*]], %[[FOR_BODY_EPIL]] ], [ %[[XTRAITER]], %[[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ] +; CHECK-NEXT: %[[AND_EPIL]] = and i64 %[[CONV]], %[[K_05_EPIL]] +; CHECK-NEXT: %[[ADD_EPIL]] = add i64 %[[AND_EPIL]], %[[G_06_EPIL]] +; CHECK-NEXT: %[[EPIL_ITER_SUB]] = add i64 %[[EPIL_ITER]], -1 +; CHECK-NEXT: %[[EPIL_ITER_CMP:.*]] = icmp eq i64 %[[EPIL_ITER_SUB]], 0 +; CHECK-NEXT: br i1 %[[EPIL_ITER_CMP]], label %[[FOR_COND_CLEANUP]], label %[[FOR_BODY_EPIL]], !llvm.loop !0 +; CHECK: [[FOR_COND_CLEANUP]]: +; CHECK-NEXT: %[[G_0_LCSSA:.*]] = phi i64 [ undef, %[[ENTRY]] ], [ %[[ADD_LCSSA_PH]], %[[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ], [ %[[ADD_EPIL]], %[[FOR_BODY_EPIL]] ] +; CHECK-NEXT: ret i64 %[[G_0_LCSSA]] +; CHECK: [[FOR_BODY]]: +; CHECK-NEXT: %[[G_06:.*]] = phi i64 [ undef, %[[FOR_BODY_LR_PH_NEW]] ], [ %[[ADD_7]], %[[FOR_BODY]] ] +; CHECK-NEXT: %[[K_05:.*]] = phi i64 [ 1, %[[FOR_BODY_LR_PH_NEW]] ], [ %[[AND]], %[[FOR_BODY]] ] +; CHECK-NEXT: %[[NITER:.*]] = phi i64 [ %[[UNROLL_ITER]], %[[FOR_BODY_LR_PH_NEW]] ], [ %[[NITER_NSUB_7:.*]], %[[FOR_BODY]] ] +; CHECK-NEXT: %[[AND]] = and i64 %[[CONV]], %[[K_05]] +; CHECK-NEXT: %[[ADD:.*]] = add i64 %[[AND]], %[[G_06]] +; CHECK-NEXT: %[[ADD_1:.*]] = add i64 %[[AND]], %[[ADD]] +; CHECK-NEXT: %[[ADD_2:.*]] = add i64 %[[AND]], %[[ADD_1]] +; CHECK-NEXT: %[[ADD_3:.*]] = add i64 %[[AND]], %[[ADD_2]] +; CHECK-NEXT: %[[ADD_4:.*]] = add i64 %[[AND]], %[[ADD_3]] +; CHECK-NEXT: %[[ADD_5:.*]] = add i64 %[[AND]], %[[ADD_4]] +; CHECK-NEXT: %[[ADD_6:.*]] = add i64 %[[AND]], %[[ADD_5]] +; CHECK-NEXT: %[[ADD_7]] = add i64 %[[AND]], %[[ADD_6]] +; CHECK-NEXT: %[[NITER_NSUB_7]] = add i64 %[[NITER]], -8 +; CHECK-NEXT: %[[NITER_NCMP_7:.*]] = icmp eq i64 %[[NITER_NSUB_7]], 0 +; CHECK-NEXT: br i1 %[[NITER_NCMP_7]], label %[[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]], label %[[FOR_BODY]] ; ; NPM-LABEL: @func( -; NPM-NEXT: entry: -; NPM-NEXT: [[CMP4:%.*]] = icmp eq i64 [[LIMIT:%.*]], 0 -; NPM-NEXT: br i1 [[CMP4]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_BODY_LR_PH:%.*]] -; NPM: for.body.lr.ph: -; NPM-NEXT: [[CONV:%.*]] = and i64 [[BLAH:%.*]], 4294967295 -; NPM-NEXT: [[TMP0:%.*]] = add i64 [[LIMIT]], -1 -; NPM-NEXT: [[XTRAITER:%.*]] = and i64 [[LIMIT]], 7 -; NPM-NEXT: [[TMP1:%.*]] = icmp ult i64 [[TMP0]], 7 -; NPM-NEXT: br i1 [[TMP1]], label [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA:%.*]], label [[FOR_BODY_LR_PH_NEW:%.*]] -; NPM: for.body.lr.ph.new: -; NPM-NEXT: [[UNROLL_ITER:%.*]] = sub i64 [[LIMIT]], [[XTRAITER]] -; NPM-NEXT: [[AND_0:%.*]] = and i64 [[CONV]], 1 -; NPM-NEXT: br label [[FOR_BODY:%.*]] -; NPM: for.cond.cleanup.loopexit.unr-lcssa: -; NPM-NEXT: [[ADD_LCSSA_PH:%.*]] = phi i64 [ undef, [[FOR_BODY_LR_PH]] ], [ [[ADD_7:%.*]], [[FOR_BODY]] ] -; NPM-NEXT: [[K_05_UNR:%.*]] = phi i64 [ 1, [[FOR_BODY_LR_PH]] ], [ [[AND_PHI:%.*]], [[FOR_BODY]] ] -; NPM-NEXT: [[LCMP_MOD:%.*]] = icmp eq i64 [[XTRAITER]], 0 -; NPM-NEXT: br i1 [[LCMP_MOD]], label [[FOR_COND_CLEANUP]], label [[FOR_BODY_EPIL:%.*]] -; NPM: for.body.epil: -; NPM-NEXT: [[G_06_EPIL:%.*]] = phi i64 [ [[ADD_EPIL:%.*]], [[FOR_BODY_EPIL]] ], [ [[ADD_LCSSA_PH]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ] -; NPM-NEXT: [[K_05_EPIL:%.*]] = phi i64 [ [[AND_EPIL:%.*]], [[FOR_BODY_EPIL]] ], [ [[K_05_UNR]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ] -; NPM-NEXT: [[EPIL_ITER:%.*]] = phi i64 [ [[EPIL_ITER_SUB:%.*]], [[FOR_BODY_EPIL]] ], [ [[XTRAITER]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ] -; NPM-NEXT: [[AND_EPIL]] = and i64 [[CONV]], [[K_05_EPIL]] -; NPM-NEXT: [[ADD_EPIL]] = add i64 [[AND_EPIL]], [[G_06_EPIL]] -; NPM-NEXT: [[EPIL_ITER_SUB]] = add i64 [[EPIL_ITER]], -1 -; NPM-NEXT: [[EPIL_ITER_CMP:%.*]] = icmp eq i64 [[EPIL_ITER_SUB]], 0 -; NPM-NEXT: br i1 [[EPIL_ITER_CMP]], label [[FOR_COND_CLEANUP]], label [[FOR_BODY_EPIL]], !llvm.loop !0 -; NPM: for.cond.cleanup: -; NPM-NEXT: [[G_0_LCSSA:%.*]] = phi i64 [ undef, [[ENTRY:%.*]] ], [ [[ADD_LCSSA_PH]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ], [ [[ADD_EPIL]], [[FOR_BODY_EPIL]] ] -; NPM-NEXT: ret i64 [[G_0_LCSSA]] -; NPM: for.body: -; NPM-NEXT: [[G_06:%.*]] = phi i64 [ undef, [[FOR_BODY_LR_PH_NEW]] ], [ [[ADD_7]], [[FOR_BODY_FOR_BODY_CRIT_EDGE:%.*]] ] -; NPM-NEXT: [[AND_PHI]] = phi i64 [ [[AND_0]], [[FOR_BODY_LR_PH_NEW]] ], [ [[AND_1:%.*]], [[FOR_BODY_FOR_BODY_CRIT_EDGE]] ] -; NPM-NEXT: [[NITER:%.*]] = phi i64 [ [[UNROLL_ITER]], [[FOR_BODY_LR_PH_NEW]] ], [ [[NITER_NSUB_7:%.*]], [[FOR_BODY_FOR_BODY_CRIT_EDGE]] ] -; NPM-NEXT: [[ADD:%.*]] = add i64 [[AND_PHI]], [[G_06]] -; NPM-NEXT: [[ADD_1:%.*]] = add i64 [[AND_PHI]], [[ADD]] -; NPM-NEXT: [[ADD_2:%.*]] = add i64 [[AND_PHI]], [[ADD_1]] -; NPM-NEXT: [[ADD_3:%.*]] = add i64 [[AND_PHI]], [[ADD_2]] -; NPM-NEXT: [[ADD_4:%.*]] = add i64 [[AND_PHI]], [[ADD_3]] -; NPM-NEXT: [[ADD_5:%.*]] = add i64 [[AND_PHI]], [[ADD_4]] -; NPM-NEXT: [[ADD_6:%.*]] = add i64 [[AND_PHI]], [[ADD_5]] -; NPM-NEXT: [[ADD_7]] = add i64 [[AND_PHI]], [[ADD_6]] -; NPM-NEXT: [[NITER_NSUB_7]] = add i64 [[NITER]], -8 -; NPM-NEXT: [[NITER_NCMP_7:%.*]] = icmp eq i64 [[NITER_NSUB_7]], 0 -; NPM-NEXT: br i1 [[NITER_NCMP_7]], label [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]], label [[FOR_BODY_FOR_BODY_CRIT_EDGE]] -; NPM: for.body.for.body_crit_edge: -; NPM-NEXT: [[AND_1]] = and i64 [[CONV]], [[AND_PHI]] -; NPM-NEXT: br label [[FOR_BODY]] +; NPM-NEXT: [[ENTRY:.*]]: +; NPM-NEXT: %[[CMP4:.*]] = icmp eq i64 %[[LIMIT:.*]], 0 +; NPM-NEXT: br i1 %[[CMP4]], label %[[FOR_COND_CLEANUP:.*]], label %[[FOR_BODY_LR_PH:.*]] +; NPM: [[FOR_BODY_LR_PH]]: +; NPM-NEXT: %[[CONV:.*]] = and i64 %[[BLAH:.*]], 4294967295 +; NPM-NEXT: %[[TMP0:.*]] = add i64 %[[LIMIT]], -1 +; NPM-NEXT: %[[XTRAITER:.*]] = and i64 %[[LIMIT]], 7 +; NPM-NEXT: %[[TMP1:.*]] = icmp ult i64 %[[TMP0]], 7 +; NPM-NEXT: br i1 %[[TMP1]], label %[[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA:.*]], label %[[FOR_BODY_LR_PH_NEW:.*]] +; NPM: [[FOR_BODY_LR_PH_NEW]]: +; NPM-NEXT: %[[UNROLL_ITER:.*]] = sub i64 %[[LIMIT]], %[[XTRAITER]] +; NPM-NEXT: %[[AND_0:.*]] = and i64 %[[CONV]], 1 +; NPM-NEXT: br label %[[FOR_BODY:.*]] +; NPM: [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]]: +; NPM-NEXT: %[[ADD_LCSSA_PH:.*]] = phi i64 [ undef, %[[FOR_BODY_LR_PH]] ], [ %[[ADD_7:.*]], %[[FOR_BODY]] ] +; NPM-NEXT: %[[K_05_UNR:.*]] = phi i64 [ 1, %[[FOR_BODY_LR_PH]] ], [ %[[AND_PHI:.*]], %[[FOR_BODY]] ] +; NPM-NEXT: %[[LCMP_MOD:.*]] = icmp eq i64 %[[XTRAITER]], 0 +; NPM-NEXT: br i1 %[[LCMP_MOD]], label %[[FOR_COND_CLEANUP]], label %[[FOR_BODY_EPIL:.*]] +; NPM: [[FOR_BODY_EPIL]]: +; NPM-NEXT: %[[G_06_EPIL:.*]] = phi i64 [ %[[ADD_EPIL:.*]], %[[FOR_BODY_EPIL]] ], [ %[[ADD_LCSSA_PH]], %[[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ] +; NPM-NEXT: %[[K_05_EPIL:.*]] = phi i64 [ %[[AND_EPIL:.*]], %[[FOR_BODY_EPIL]] ], [ %[[K_05_UNR]], %[[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ] +; NPM-NEXT: %[[EPIL_ITER:.*]] = phi i64 [ %[[EPIL_ITER_SUB:.*]], %[[FOR_BODY_EPIL]] ], [ %[[XTRAITER]], %[[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ] +; NPM-NEXT: %[[AND_EPIL]] = and i64 %[[CONV]], %[[K_05_EPIL]] +; NPM-NEXT: %[[ADD_EPIL]] = add i64 %[[AND_EPIL]], %[[G_06_EPIL]] +; NPM-NEXT: %[[EPIL_ITER_SUB]] = add i64 %[[EPIL_ITER]], -1 +; NPM-NEXT: %[[EPIL_ITER_CMP:.*]] = icmp eq i64 %[[EPIL_ITER_SUB]], 0 +; NPM-NEXT: br i1 %[[EPIL_ITER_CMP]], label %[[FOR_COND_CLEANUP]], label %[[FOR_BODY_EPIL]], !llvm.loop !0 +; NPM: [[FOR_COND_CLEANUP]]: +; NPM-NEXT: %[[G_0_LCSSA:.*]] = phi i64 [ undef, %[[ENTRY]] ], [ %[[ADD_LCSSA_PH]], %[[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ], [ %[[ADD_EPIL]], %[[FOR_BODY_EPIL]] ] +; NPM-NEXT: ret i64 %[[G_0_LCSSA]] +; NPM: [[FOR_BODY]]: +; NPM-NEXT: %[[G_06:.*]] = phi i64 [ undef, %[[FOR_BODY_LR_PH_NEW]] ], [ %[[ADD_7]], %[[FOR_BODY_FOR_BODY_CRIT_EDGE:.*]] ] +; NPM-NEXT: %[[AND_PHI]] = phi i64 [ %[[AND_0]], %[[FOR_BODY_LR_PH_NEW]] ], [ %[[AND_1:.*]], %[[FOR_BODY_FOR_BODY_CRIT_EDGE]] ] +; NPM-NEXT: %[[NITER:.*]] = phi i64 [ %[[UNROLL_ITER]], %[[FOR_BODY_LR_PH_NEW]] ], [ %[[NITER_NSUB_7:.*]], %[[FOR_BODY_FOR_BODY_CRIT_EDGE]] ] +; NPM-NEXT: %[[ADD:.*]] = add i64 %[[AND_PHI]], %[[G_06]] +; NPM-NEXT: %[[ADD_1:.*]] = add i64 %[[AND_PHI]], %[[ADD]] +; NPM-NEXT: %[[ADD_2:.*]] = add i64 %[[AND_PHI]], %[[ADD_1]] +; NPM-NEXT: %[[ADD_3:.*]] = add i64 %[[AND_PHI]], %[[ADD_2]] +; NPM-NEXT: %[[ADD_4:.*]] = add i64 %[[AND_PHI]], %[[ADD_3]] +; NPM-NEXT: %[[ADD_5:.*]] = add i64 %[[AND_PHI]], %[[ADD_4]] +; NPM-NEXT: %[[ADD_6:.*]] = add i64 %[[AND_PHI]], %[[ADD_5]] +; NPM-NEXT: %[[ADD_7]] = add i64 %[[AND_PHI]], %[[ADD_6]] +; NPM-NEXT: %[[NITER_NSUB_7]] = add i64 %[[NITER]], -8 +; NPM-NEXT: %[[NITER_NCMP_7:.*]] = icmp eq i64 %[[NITER_NSUB_7]], 0 +; NPM-NEXT: br i1 %[[NITER_NCMP_7]], label %[[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]], label %[[FOR_BODY_FOR_BODY_CRIT_EDGE]] +; NPM: [[FOR_BODY_FOR_BODY_CRIT_EDGE]]: +; NPM-NEXT: %[[AND_1]] = and i64 %[[CONV]], %[[AND_PHI]] +; NPM-NEXT: br label %[[FOR_BODY]] ; entry: %blah.addr = alloca i64, align 8 Index: llvm/utils/UpdateTestChecks/common.py =================================================================== --- llvm/utils/UpdateTestChecks/common.py +++ llvm/utils/UpdateTestChecks/common.py @@ -136,7 +136,11 @@ # Match things that look at identifiers, but only if they are followed by # spaces, commas, paren, or end of the string -IR_VALUE_RE = re.compile(r'(\s+)%([\w\.\-]+?)([,\s\(\)]|\Z)') +IR_VALUE_WITH_PERCENT_RE = re.compile(r'(\s+%)([\w\.\-]+?)([,\s\(\)]|\Z)') +IR_VALUE_RE = re.compile(r'(\s+%)([\w\.\-]+?)([,\s\(\)]|\Z)') + +# Match things that end with colon +IR_LABEL_RE = re.compile(r'^()([\w\.\-]+)(:)$') # Create a FileCheck variable name based on an IR name. def get_value_name(var): @@ -149,7 +153,7 @@ # Create a FileCheck variable from regex. def get_value_definition(var): - return '[[' + get_value_name(var) + ':%.*]]' + return '[[' + get_value_name(var) + ':.*]]' # Use a FileCheck variable. @@ -157,7 +161,7 @@ return '[[' + get_value_name(var) + ']]' # Replace IR value defs and uses with FileCheck variables. -def genericize_check_lines(lines, is_analyze): +def genericize_check_lines(lines, is_analyze, gen_var_block_name): # This gets called for each match that occurs in # a line. We transform variables we haven't seen # into defs, and variables we have seen into uses. @@ -183,13 +187,17 @@ # Ignore any comments, since the check lines will too. scrubbed_line = SCRUB_IR_COMMENT_RE.sub(r'', line) if is_analyze == False: - lines[i] = IR_VALUE_RE.sub(transform_line_vars, scrubbed_line) + if gen_var_block_name == True: + lines[i] = IR_VALUE_RE.sub(transform_line_vars, scrubbed_line) + lines[i] = IR_LABEL_RE.sub(transform_line_vars, lines[i]) + else: + lines[i] = IR_VALUE_WITH_PERCENT_RE.sub(transform_line_vars, scrubbed_line) else: lines[i] = scrubbed_line return lines -def add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name, check_label_format, is_asm, is_analyze): +def add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name, check_label_format, is_asm, is_analyze, gen_var_block_name): printed_prefixes = [] for p in prefix_list: checkprefixes = p[0] @@ -220,7 +228,7 @@ # For IR output, change all defs to FileCheck variables, so we're immune # to variable naming fashions. - func_body = genericize_check_lines(func_body, is_analyze) + func_body = genericize_check_lines(func_body, is_analyze, gen_var_block_name) # This could be selectively enabled with an optional invocation argument. # Disabled for now: better to check everything. Be safe rather than sorry. @@ -256,11 +264,11 @@ output_lines.append(comment_marker) break -def add_ir_checks(output_lines, comment_marker, prefix_list, func_dict, func_name): +def add_ir_checks(output_lines, comment_marker, prefix_list, func_dict, func_name, gen_var_block_name): # Label format is based on IR string. check_label_format = '{} %s-LABEL: @%s('.format(comment_marker) - add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name, check_label_format, False, False) + add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name, check_label_format, False, False, gen_var_block_name) def add_analyze_checks(output_lines, comment_marker, prefix_list, func_dict, func_name): check_label_format = '{} %s-LABEL: \'%s\''.format(comment_marker) - add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name, check_label_format, False, True) + add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name, check_label_format, False, True, False) Index: llvm/utils/update_test_checks.py =================================================================== --- llvm/utils/update_test_checks.py +++ llvm/utils/update_test_checks.py @@ -62,6 +62,8 @@ help='The opt binary used to generate the test case') parser.add_argument( '--function', help='The function in the test file to update') + parser.add_argument('--varblocknames', action='store_true', + help='Generate basic block names as variables') parser.add_argument('tests', nargs='+') args = parser.parse_args() @@ -157,7 +159,7 @@ continue # Print out the various check lines here. - common.add_ir_checks(output_lines, ';', prefix_list, func_dict, func_name) + common.add_ir_checks(output_lines, ';', prefix_list, func_dict, func_name, args.varblocknames) is_in_function_start = False if is_in_function: