From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Christopher Li <sparse@chrisli.org>,
Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH] simplify float-to-float casts that doesn't change size
Date: Thu, 16 Feb 2017 03:58:31 +0100 [thread overview]
Message-ID: <20170216025831.25449-1-luc.vanoostenryck@gmail.com> (raw)
---
simplify.c | 2 ++
validation/optim/fpcast-nop.c | 15 +++++++++++++++
2 files changed, 17 insertions(+)
create mode 100644 validation/optim/fpcast-nop.c
diff --git a/simplify.c b/simplify.c
index 2a1f0b200..3085c39f4 100644
--- a/simplify.c
+++ b/simplify.c
@@ -895,6 +895,8 @@ static int simplify_cast(struct instruction *insn)
int op = (orig_type->ctype.modifiers & MOD_SIGNED) ? OP_SCAST : OP_CAST;
if (insn->opcode == op)
goto simplify;
+ if (insn->opcode == OP_FPCAST && is_float_type(orig_type))
+ goto simplify;
}
return 0;
diff --git a/validation/optim/fpcast-nop.c b/validation/optim/fpcast-nop.c
new file mode 100644
index 000000000..c2e7ba87f
--- /dev/null
+++ b/validation/optim/fpcast-nop.c
@@ -0,0 +1,15 @@
+static float foof( float a) { return ( float) a; }
+static double food(double a) { return (double) a; }
+static long double fool(long double a) { return (long double) a; }
+
+/*
+ * check-name: fpcast-nop
+ * check-description:
+ * Verify that unneeded casts between same-type
+ * floats are also optimized away.
+ *
+ * check-command: test-linearize $file
+ * check-output-ignore
+ *
+ * check-output-excludes: fpcast\\.
+ */
--
2.11.0
next reply other threads:[~2017-02-16 2:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-16 2:58 Luc Van Oostenryck [this message]
2017-02-16 12:41 ` [PATCH] simplify float-to-float casts that doesn't change size Christopher Li
2017-02-16 13:53 ` Luc Van Oostenryck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170216025831.25449-1-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox