(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
tree-ssa/
pr70232.c
       1  /* { dg-do compile } */
       2  /* { dg-options "-O2 -w -fdump-tree-vrp1-details -fdump-tree-vrp2-details -fdump-tree-dom2-details -fdump-tree-dom3-details" } */
       3  
       4  /* All the threads found by the threader should have too many
       5     statements to be profitable.  */
       6  /* { dg-final { scan-tree-dump-not "Registering jump " "dom2"} } */
       7  /* { dg-final { scan-tree-dump-not "Registering jump " "dom3"} } */
       8  /* { dg-final { scan-tree-dump-not "Registering jump " "vrp1"} } */
       9  /* { dg-final { scan-tree-dump-not "Registering jump " "vrp2"} } */
      10  
      11  typedef _Bool bool;
      12  typedef unsigned char uint8_t;
      13  typedef unsigned long uint32_t;
      14  typedef unsigned long long uint64_t;
      15  typedef unsigned int size_t;
      16  
      17  enum {
      18   false = 0,
      19   true = 1
      20  };
      21  
      22  struct list_head {
      23   struct list_head *next, *prev;
      24  };
      25  
      26  
      27  extern void * memcpy(void *, const void *, size_t);
      28  extern int memcmp(const void *,const void *,size_t);
      29  extern void * memset(void *, int, size_t);
      30  extern void __memzero(void *ptr, size_t n);
      31  
      32  static inline uint64_t wwn_to_uint64_t(uint8_t *wwn)
      33  {
      34   return (uint64_t)wwn[0] << 56 | (uint64_t)wwn[1] << 48 |
      35       (uint64_t)wwn[2] << 40 | (uint64_t)wwn[3] << 32 |
      36       (uint64_t)wwn[4] << 24 | (uint64_t)wwn[5] << 16 |
      37       (uint64_t)wwn[6] << 8 | (uint64_t)wwn[7];
      38  }
      39  
      40  struct lpfc_name {
      41   union {
      42    uint8_t wwn[8];
      43   } u;
      44  };
      45  
      46  struct lpfc_hba {
      47   uint32_t cfg_fof;
      48   uint32_t cfg_oas_flags;
      49   struct list_head luns;
      50  };
      51  
      52  struct lpfc_device_id {
      53   struct lpfc_name vport_wwpn;
      54   struct lpfc_name target_wwpn;
      55   uint64_t lun;
      56  };
      57  
      58  struct lpfc_device_data {
      59   struct list_head listentry;
      60   struct lpfc_device_id device_id;
      61   bool oas_enabled;
      62   bool available;
      63  };
      64  
      65  bool
      66  lpfc_find_next_oas_lun(struct lpfc_hba *phba, struct lpfc_name *vport_wwpn,
      67           struct lpfc_name *target_wwpn, uint64_t *starting_lun,
      68           struct lpfc_name *found_vport_wwpn,
      69           struct lpfc_name *found_target_wwpn,
      70           uint64_t *found_lun,
      71           uint32_t *found_lun_status)
      72  {
      73  
      74   struct lpfc_device_data *lun_info;
      75   struct lpfc_device_id *device_id;
      76   uint64_t lun;
      77   bool found = false;
      78  
      79   if (__builtin_expect(!!(!phba), 0) || !vport_wwpn || !target_wwpn ||
      80       !starting_lun || !found_vport_wwpn ||
      81       !found_target_wwpn || !found_lun || !found_lun_status ||
      82       (*starting_lun == -1u) ||
      83       !phba->cfg_fof)
      84    return false;
      85  
      86   lun = *starting_lun;
      87   *found_lun = -1;
      88   *starting_lun = -1;
      89  
      90  
      91  
      92   for (lun_info = ({ const typeof( ((typeof(*lun_info) *)0)->listentry ) *__mptr = ((&phba->luns)->next); (typeof(*lun_info) *)( (char *)__mptr - __builtin_offsetof(typeof(*lun_info), listentry) );}); &lun_info->listentry != (&phba->luns); lun_info = ({ const typeof( ((typeof(*(lun_info)) *)0)->listentry ) *__mptr = ((lun_info)->listentry.next); (typeof(*(lun_info)) *)( (char *)__mptr - __builtin_offsetof(typeof(*(lun_info)), listentry) );})) {
      93    if (((wwn_to_uint64_t(vport_wwpn->u.wwn) == 0) ||
      94         (memcmp(&lun_info->device_id.vport_wwpn, vport_wwpn,
      95         sizeof(struct lpfc_name)) == 0)) &&
      96        ((wwn_to_uint64_t(target_wwpn->u.wwn) == 0) ||
      97         (memcmp(&lun_info->device_id.target_wwpn, target_wwpn,
      98         sizeof(struct lpfc_name)) == 0)) &&
      99        (lun_info->oas_enabled)) {
     100     device_id = &lun_info->device_id;
     101     if ((!found) && ((lun == 0) || (device_id->lun == lun))) {
     102      *found_lun = device_id->lun;
     103      memcpy(found_vport_wwpn, &device_id->vport_wwpn, sizeof(struct lpfc_name));
     104      memcpy(found_target_wwpn, &device_id->target_wwpn, sizeof(struct lpfc_name));
     105      if (lun_info->available)
     106       *found_lun_status = 0x01;
     107      else
     108       *found_lun_status = 0;
     109      if (phba->cfg_oas_flags & 0x01)
     110       ({ void *__p = (vport_wwpn); size_t __n = sizeof(struct lpfc_name); if ((__n) != 0) { if (__builtin_constant_p((0x0)) && (0x0) == 0) __memzero((__p),(__n)); else memset((__p),(0x0),(__n)); } (__p); })
     111                                       ;
     112      if (phba->cfg_oas_flags & 0x02)
     113       ({ void *__p = (target_wwpn); size_t __n = sizeof(struct lpfc_name); if ((__n) != 0) { if (__builtin_constant_p((0x0)) && (0x0) == 0) __memzero((__p),(__n)); else memset((__p),(0x0),(__n)); } (__p); })
     114                                       ;
     115      found = true;
     116     } else if (found) {
     117      *starting_lun = device_id->lun;
     118      memcpy(vport_wwpn, &device_id->vport_wwpn,
     119             sizeof(struct lpfc_name));
     120      memcpy(target_wwpn, &device_id->target_wwpn,
     121             sizeof(struct lpfc_name));
     122      break;
     123     }
     124    }
     125   }
     126   return found;
     127  }
     128  
     129