public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, AArch64, AArch64-4.7] Implement Bitwise AND and Set Flags
@ 2013-01-29 13:50 Hurugalawadi, Naveen
  0 siblings, 0 replies; only message in thread
From: Hurugalawadi, Naveen @ 2013-01-29 13:50 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 648 bytes --]

Hi,

Please find attached the patch that implements Bitwise AND and Set
Flags instruction for aarch64 target.
The patch adds a testcase ands.c which is similar to the adds.c.

Please review the patch and let me know if there should be any
modifications?

Regressed for aarch64-elf on aarch64-4.7-branch.

Thanks,
Naveen.H.S

gcc/

2013-01-29   Naveen H.S  <Naveen.Hurugalawadi@caviumnetworks.com>

	* config/aarch64/aarch64.md (*and<mode>3_compare0): New pattern.
	(*andsi3_compare0_uxtw): New pattern.

gcc/testsuite/

2013-01-29   Naveen H.S  <Naveen.Hurugalawadi@caviumnetworks.com>

	* gcc.target/aarch64/ands.c: New.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ands_4.7.patch --]
[-- Type: text/x-patch; name="ands_4.7.patch", Size: 1892 bytes --]

--- gcc/config/aarch64/aarch64.md	2013-01-25 15:52:09.214218793 +0530
+++ gcc/config/aarch64/aarch64.md	2013-01-29 18:51:46.965821291 +0530
@@ -2370,6 +2370,35 @@
   [(set_attr "v8type" "logic,logic_imm")
    (set_attr "mode" "<MODE>")])
 
+(define_insn "*and<mode>3_compare0"
+  [(set (reg:CC CC_REGNUM)
+	(compare:CC
+	 (and:GPI (match_operand:GPI 1 "register_operand" "%r,r")
+		  (match_operand:GPI 2 "aarch64_logical_operand" "r,<lconst>"))
+	 (const_int 0)))
+   (set (match_operand:GPI 0 "register_operand" "=r,r")
+	(and:GPI (match_dup 1) (match_dup 2)))]
+  ""
+  "ands\\t%<w>0, %<w>1, %<w>2"
+  [(set_attr "v8type" "logic,logic_imm")
+   (set_attr "mode" "<MODE>")]
+)
+
+;; zero_extend version of above
+(define_insn "*andsi3_compare0_uxtw"
+  [(set (reg:CC CC_REGNUM)
+	(compare:CC
+	 (and:SI (match_operand:SI 1 "register_operand" "%r,r")
+		 (match_operand:SI 2 "aarch64_logical_operand" "r,K"))
+	 (const_int 0)))
+   (set (match_operand:DI 0 "register_operand" "=r,r")
+	(zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))]
+  ""
+  "ands\\t%w0, %w1, %w2"
+  [(set_attr "v8type" "logic,logic_imm")
+   (set_attr "mode" "SI")]
+)
+
 (define_insn "*<LOGICAL:optab>_<SHIFT:optab><mode>3"
   [(set (match_operand:GPI 0 "register_operand" "=r")
 	(LOGICAL:GPI (SHIFT:GPI
--- gcc/testsuite/gcc.target/aarch64/ands.c	1970-01-01 05:30:00.000000000 +0530
+++ gcc/testsuite/gcc.target/aarch64/ands.c	2013-01-29 16:10:23.817675842 +0530
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int z;
+int
+foo (int x, int y)
+{
+  int l = x & y;
+  if (l == 0)
+    return 5;
+
+  /* { dg-final { scan-assembler "ands\tw\[0-9\]" } } */
+  z = l ;
+  return 25;
+}
+
+typedef long long s64;
+
+s64 zz;
+s64
+foo2 (s64 x, s64 y)
+{
+  s64 l = x & y;
+  if (l < 0)
+    return 5;
+
+  /* { dg-final { scan-assembler "ands\tx\[0-9\]" } } */
+  zz = l ;
+  return 25;
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-01-29 13:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-29 13:50 [Patch, AArch64, AArch64-4.7] Implement Bitwise AND and Set Flags Hurugalawadi, Naveen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).