[llvm] Add parentheses around '&&' within '||' (PR #170652)

Konrad Kleine via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 4 04:47:25 PST 2025


https://github.com/kwk updated https://github.com/llvm/llvm-project/pull/170652

>From 2401dfaaae38e42460dbc327d732d5c7e282a087 Mon Sep 17 00:00:00 2001
From: Konrad Kleine <kkleine at redhat.com>
Date: Thu, 4 Dec 2025 12:26:11 +0000
Subject: [PATCH] Add parentheses around '&&' within '||'
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

```
/home/fedora/src/llvm-project/main/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp:3358
79: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
 3358 |          (getImm(I.getOperand(4), MRI) && foldImm(I.getOperand(4), MRI) == 0) &&
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
 3359 |              "Cannot translate GEP to OpAccessChain. First index must be 0.");
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
---
 llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
index a2e29366dc4cc..df958d2c86b33 100644
--- a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
@@ -3353,10 +3353,11 @@ bool SPIRVInstructionSelector::selectGEP(Register ResVReg,
                  .addUse(GR.getSPIRVTypeID(ResType))
                  // Object to get a pointer to.
                  .addUse(I.getOperand(3).getReg());
-  assert(Opcode == SPIRV::OpPtrAccessChain ||
-         Opcode == SPIRV::OpInBoundsPtrAccessChain ||
-         (getImm(I.getOperand(4), MRI) && foldImm(I.getOperand(4), MRI) == 0) &&
-             "Cannot translate GEP to OpAccessChain. First index must be 0.");
+  assert(
+      (Opcode == SPIRV::OpPtrAccessChain ||
+       Opcode == SPIRV::OpInBoundsPtrAccessChain ||
+       (getImm(I.getOperand(4), MRI) && foldImm(I.getOperand(4), MRI) == 0)) &&
+      "Cannot translate GEP to OpAccessChain. First index must be 0.");
 
   // Adding indices.
   const unsigned StartingIndex =



More information about the llvm-commits mailing list