On Wed, Oct 30, 2013 at 9:02 PM, Cong Hou <co...@google.com> wrote: > I have run check_GNU_style.sh on my patch. > > The patch is submitted. Thank you for your comments and help on this patch!
I have committed a couple of fixes/improvements to your expander in i386.c. There is no need to check for the result of expand_simple_binop. Also, there is no guarantee that expand_simple_binop will expand to the target. It can return different RTX. Also, unhandled modes are now marked with gcc_unreachable. 2013-10-31 Uros Bizjak <ubiz...@gmail.com> * config/i386/i386.c (ix86_expand_sse2_abs): Rename function arguments. Use gcc_unreachable for unhandled modes. Do not check results of expand_simple_binop. If not expanded to target, move the result. Tested on x86_64-pc-linux-gnu and committed. Uros.
Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 204264) +++ config/i386/i386.c (working copy) @@ -42020,36 +42020,36 @@ return false; } +/* Calculate integer abs() using only SSE2 instructions. */ + void -ix86_expand_sse2_abs (rtx op0, rtx op1) +ix86_expand_sse2_abs (rtx target, rtx input) { enum machine_mode mode = GET_MODE (op0); - rtx tmp0, tmp1; + rtx tmp0, tmp1, x; switch (mode) { /* For 32-bit signed integer X, the best way to calculate the absolute value of X is (((signed) X >> (W-1)) ^ X) - ((signed) X >> (W-1)). */ case V4SImode: - tmp0 = expand_simple_binop (mode, ASHIFTRT, op1, + tmp0 = expand_simple_binop (mode, ASHIFTRT, input, GEN_INT (GET_MODE_BITSIZE - (GET_MODE_INNER (mode)) - 1), + (GET_MODE_INNER (mode)) - 1), NULL, 0, OPTAB_DIRECT); - if (tmp0) - tmp1 = expand_simple_binop (mode, XOR, op1, tmp0, - NULL, 0, OPTAB_DIRECT); - if (tmp0 && tmp1) - expand_simple_binop (mode, MINUS, tmp1, tmp0, - op0, 0, OPTAB_DIRECT); + tmp1 = expand_simple_binop (mode, XOR, tmp0, input, + NULL, 0, OPTAB_DIRECT); + x = expand_simple_binop (mode, MINUS, tmp1, tmp0, + output, 0, OPTAB_DIRECT); break; /* For 16-bit signed integer X, the best way to calculate the absolute value of X is max (X, -X), as SSE2 provides the PMAXSW insn. */ case V8HImode: tmp0 = expand_unop (mode, neg_optab, op1, NULL_RTX, 0); - if (tmp0) - expand_simple_binop (mode, SMAX, op1, tmp0, op0, 0, - OPTAB_DIRECT); + + x = expand_simple_binop (mode, SMAX, tmp0, input, + output, 0, OPTAB_DIRECT); break; /* For 8-bit signed integer X, the best way to calculate the absolute @@ -42057,14 +42057,17 @@ as SSE2 provides the PMINUB insn. */ case V16QImode: tmp0 = expand_unop (mode, neg_optab, op1, NULL_RTX, 0); - if (tmp0) - expand_simple_binop (V16QImode, UMIN, op1, tmp0, op0, 0, - OPTAB_DIRECT); + + x = expand_simple_binop (V16QImode, UMIN, tmp0, input, + output, 0, OPTAB_DIRECT); break; default: - break; + gcc_unreachable (); } + + if (x != output) + emit_move_insn (output, x); } /* Expand an insert into a vector register through pinsr insn.