[PATCH] simplify float-to-float casts that doesn't change size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux