View | Details | Return to bug 57157 | Differences between
and this patch

Collapse All | Expand All

(-)fold-const.c (+52 lines)
Lines 10446-10465 fold_binary_loc (location_t loc, Link Here
10446
							  (arg0, 0))))
10446
							  (arg0, 0))))
10447
		    && operand_equal_p (tree11, tree011, 0))
10447
		    && operand_equal_p (tree11, tree011, 0))
10448
		    return fold_convert_loc
10448
		    return fold_convert_loc
10449
		      (loc, type,
10449
		      (loc, type,
10450
		       build2 ((code0 != LSHIFT_EXPR
10450
		       build2 ((code0 != LSHIFT_EXPR
10451
				? LROTATE_EXPR
10451
				? LROTATE_EXPR
10452
				: RROTATE_EXPR),
10452
				: RROTATE_EXPR),
10453
			       TREE_TYPE (TREE_OPERAND (arg0, 0)),
10453
			       TREE_TYPE (TREE_OPERAND (arg0, 0)),
10454
			       TREE_OPERAND (arg0, 0), tree11));
10454
			       TREE_OPERAND (arg0, 0), tree11));
10455
	      }
10455
	      }
10456
	    else if (code11 == BIT_AND_EXPR)
10457
	      {
10458
		tree tree110, tree111;
10459
		tree110 = TREE_OPERAND (tree11, 0);
10460
		tree111 = TREE_OPERAND (tree11, 1);
10461
		STRIP_NOPS (tree110);
10462
		STRIP_NOPS (tree111);
10463
		enum tree_code code110 = TREE_CODE (tree110);
10464
		enum tree_code code111 = TREE_CODE (tree111);
10465
		if (code110 == NEGATE_EXPR
10466
		    && operand_equal_p (tree01,
10467
			 tree_strip_nop_conversions (TREE_OPERAND (tree110, 0)),
10468
			 0)
10469
		    && code111 == INTEGER_CST
10470
		    && 0 == compare_tree_int (tree111,
10471
					      TYPE_PRECISION
10472
					      (TREE_TYPE (TREE_OPERAND
10473
							  (arg0, 0))) - 1))
10474
		  return fold_convert_loc
10475
		    (loc, type,
10476
		     build2 ((code0 == LSHIFT_EXPR
10477
			      ? LROTATE_EXPR
10478
			      : RROTATE_EXPR),
10479
			     TREE_TYPE (TREE_OPERAND (arg0, 0)),
10480
			     TREE_OPERAND (arg0, 0), tree01));
10481
	      }
10482
	    else if (code01 == BIT_AND_EXPR)
10483
	      {
10484
		tree tree010, tree011;
10485
		tree010 = TREE_OPERAND (tree01, 0);
10486
		tree011 = TREE_OPERAND (tree01, 1);
10487
		STRIP_NOPS (tree010);
10488
		STRIP_NOPS (tree011);
10489
		enum tree_code code010 = TREE_CODE (tree010);
10490
		enum tree_code code011 = TREE_CODE (tree011);
10491
		if (code010 == NEGATE_EXPR
10492
		    && operand_equal_p (tree11,
10493
			 tree_strip_nop_conversions (TREE_OPERAND (tree010, 0)),
10494
			 0)
10495
		    && code011 == INTEGER_CST
10496
		    && 0 == compare_tree_int (tree011,
10497
					      TYPE_PRECISION
10498
					      (TREE_TYPE (TREE_OPERAND
10499
							  (arg1, 0))) - 1))
10500
		  return fold_convert_loc
10501
		    (loc, type,
10502
		     build2 ((code0 != LSHIFT_EXPR
10503
			      ? LROTATE_EXPR
10504
			      : RROTATE_EXPR),
10505
			     TREE_TYPE (TREE_OPERAND (arg1, 0)),
10506
			     TREE_OPERAND (arg1, 0), tree11));
10507
	      }
10456
	  }
10508
	  }
10457
      }
10509
      }
10458
10510
10459
    associate:
10511
    associate:
10460
      /* In most languages, can't associate operations on floats through
10512
      /* In most languages, can't associate operations on floats through
10461
	 parentheses.  Rather than remember where the parentheses were, we
10513
	 parentheses.  Rather than remember where the parentheses were, we
10462
	 don't associate floats at all, unless the user has specified
10514
	 don't associate floats at all, unless the user has specified
10463
	 -fassociative-math.
10515
	 -fassociative-math.
10464
	 And, we need to make sure type is not saturating.  */
10516
	 And, we need to make sure type is not saturating.  */
10465
10517

Return to bug 57157