https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106907

            Bug ID: 106907
           Summary: gcc/config/rs6000/rs6000.cc:23155: strange expression
                    ?
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

Static analyser cppcheck says:

gcc/config/rs6000/rs6000.cc:23155:16: style: Boolean result is used in bitwise
operation. Clarify expression with parentheses. [clarifyCondition]

Source code is

  fprintf (file, "\t  .amdhsa_system_vgpr_workitem_id\t%i\n",
       (cfun->machine->args.requested & (1 << WORK_ITEM_ID_Z_ARG))
       ? 2
       : cfun->machine->args.requested & (1 << WORK_ITEM_ID_Y_ARG)
       ? 1 : 0);

Maybe better code:

  fprintf (file, "\t  .amdhsa_system_vgpr_workitem_id\t%i\n",
       (cfun->machine->args.requested & (1 << WORK_ITEM_ID_Z_ARG))
       ? 2
       : (cfun->machine->args.requested & (1 << WORK_ITEM_ID_Y_ARG))
       ? 1 : 0);

Reply via email to