When either op0 or op1 is a constant, expand_binop can emit an extra AND
during expansion. Use simplify_expand_binop here to avoid creating it in
the first place.

gcc/ChangeLog:

        * dojump.cc (do_compare_rtx_and_jump): Use simplify_expand_binop
        instead of expand_binop.
---
 gcc/dojump.cc | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/gcc/dojump.cc b/gcc/dojump.cc
index 599a546b0de..1ed22116a27 100644
--- a/gcc/dojump.cc
+++ b/gcc/dojump.cc
@@ -1244,12 +1244,11 @@ do_compare_rtx_and_jump (rtx op0, rtx op1, enum 
rtx_code code, int unsignedp,
          auto nunits = TYPE_VECTOR_SUBPARTS (TREE_TYPE (val)).to_constant ();
          if (maybe_ne (GET_MODE_PRECISION (mode), nunits))
            {
-             op0 = expand_binop (mode, and_optab, op0,
-                                 GEN_INT ((HOST_WIDE_INT_1U << nunits) - 1),
-                                 NULL_RTX, true, OPTAB_WIDEN);
-             op1 = expand_binop (mode, and_optab, op1,
-                                 GEN_INT ((HOST_WIDE_INT_1U << nunits) - 1),
-                                 NULL_RTX, true, OPTAB_WIDEN);
+             rtx mask_imm = GEN_INT ((HOST_WIDE_INT_1U << nunits) - 1);
+             op0 = simplify_expand_binop (mode, and_optab, op0, mask_imm,
+                                          NULL_RTX, true, OPTAB_WIDEN);
+             op1 = simplify_expand_binop (mode, and_optab, op1, mask_imm,
+                                          NULL_RTX, true, OPTAB_WIDEN);
            }
        }
 
-- 
2.31.1

Reply via email to