aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/avr/uint8-single-reg.c
blob: 291b56cd6eb203fd32c982afcd6dfcbb06d1c89c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* { dg-do compile } */
/* { dg-options "-Os" } */

/* This testcase verifies that a uint8_t variable assigned from a wider variable
   with the same range is held in a single register. VRP must not fold away the
   conversion and use two regs to hold the uint16_t - widenings are ok only upto 
   word mode (1 byte for AVR).
*/

unsigned int foo(const unsigned int wvalue)
{
  const unsigned char type = (wvalue >> 8);
  unsigned int size = 0;

  if (type == 1)
  {
    size = 20;
  }
  return size;
}

/* { dg-final { scan-assembler "cpi r25,lo8\\(1\\)" } } */
/* { dg-final { scan-assembler-not "cpc r\\d+,__zero_reg__" } } */