From 680ef2c8eafa102d8ed5866d5ccf2872f5d0f269 Mon Sep 17 00:00:00 2001 From: Andreas Klebinger Date: Fri, 12 Nov 2021 15:45:18 +0100 Subject: CmmSink: Be more aggressive in removing no-op assignments. No-op assignments like R1 = R1 are not only wasteful. They can also inhibit other optimizations like inlining assignments that read from R1. We now check for assignments being a no-op before and after we simplify the RHS in Cmm sink which should eliminate most of these no-ops. --- testsuite/driver/testlib.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'testsuite/driver/testlib.py') diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py index efeaa94b89..d4c8fc38f7 100644 --- a/testsuite/driver/testlib.py +++ b/testsuite/driver/testlib.py @@ -800,9 +800,26 @@ def check_errmsg(needle): return "%s not contained in -ddump-simpl\n" % needle return normalise_errmsg_fun(norm) -def grep_errmsg(needle): - def norm(str): - return "".join(filter(lambda l: re.search(needle, l), str.splitlines(True))) +# grep_errmsg(regex,[match_only]) +# If match_only = True we only check the part of the error +# that matches the regex. +def grep_errmsg(needle:str, match_only = False): + + def get_match(str:str): + m = re.search(needle,str) + if m: + return m.group(0) + else: + return None + + def norm(str) -> str: + if not match_only: + return "".join( filter(lambda l: re.search(needle,l), + str.splitlines(True))) + else: + matches = [get_match(x) for x in str.splitlines(True)] + res = "\n".join([x for x in matches if x]) + return res return normalise_errmsg_fun(norm) def multiline_grep_errmsg(needle): -- cgit v1.2.1