This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/2] simplify-rtx: Simplify trunc of and of shiftrt


On 11/09/2015 08:33 AM, Segher Boessenkool wrote:
If we have

	(truncate:M1 (and:M2 (lshiftrt:M2 (x:M2) C) C2))

we can write it instead as

	(and:M1 (lshiftrt:M1 (truncate:M1 (x:M2)) C) C2)


+  /* Likewise (truncate:QI (and:SI (lshiftrt:SI (x:SI) C) C2)) into
+     (and:QI (lshiftrt:QI (truncate:QI (x:SI)) C) C2) for suitable C
+     and C2.  */
+  if (GET_CODE (op) == AND
+      && (GET_CODE (XEXP (op, 0)) == LSHIFTRT
+	  || GET_CODE (XEXP (op, 0)) == ASHIFTRT)
+      && CONST_INT_P (XEXP (XEXP (op, 0), 1))
+      && CONST_INT_P (XEXP (op, 1))
+      && UINTVAL (XEXP (XEXP (op, 0), 1)) < precision
+      && ((GET_MODE_MASK (mode) >> UINTVAL (XEXP (XEXP (op, 0), 1)))
+	  & UINTVAL (XEXP (op, 1)))
+	 == ((GET_MODE_MASK (op_mode) >> UINTVAL (XEXP (XEXP (op, 0), 1)))
+	     & UINTVAL (XEXP (op, 1))))

In general this would be easier to read if there were intermediate variables called shift_amount and mask. I'm not entirely sure what the last condition here is supposed to test. Is it related to...

+	    return simplify_gen_binary (AND, mode, op0, XEXP (op, 1));

... the fact that here I think you'd have to trunc_int_for_mode the AND amount for the smaller mode?


Bernd


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]