[AMDGPU] Fix gcc warnings
authorSebastian Neubauer <sebastian.neubauer@amd.com>
Tue, 6 Oct 2020 08:45:31 +0000 (10:45 +0200)
committerSebastian Neubauer <sebastian.neubauer@amd.com>
Tue, 6 Oct 2020 08:55:08 +0000 (10:55 +0200)
uint8_t types are implicitly promoted to int, leading to a
unsigned-signed comparison.

Thanks for the heads-up @uabelho.

Differential Revision: https://reviews.llvm.org/D88876

llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp

index fa3130a..f141ca1 100644 (file)
@@ -3942,8 +3942,10 @@ static void packImageA16AddressToDwords(
       // derivatives dx/dh and dx/dv are packed with undef.
       if (((I + 1) >= EndIdx) ||
           ((Intr->NumGradients / 2) % 2 == 1 &&
-           (I == Intr->GradientStart + (Intr->NumGradients / 2) - 1 ||
-            I == Intr->GradientStart + Intr->NumGradients - 1)) ||
+           (I == static_cast<unsigned>(Intr->GradientStart +
+                                       (Intr->NumGradients / 2) - 1) ||
+            I == static_cast<unsigned>(Intr->GradientStart +
+                                       Intr->NumGradients - 1))) ||
           // Check for _L to _LZ optimization
           !MI.getOperand(ArgOffset + I + 1).isReg()) {
         PackedAddrs.push_back(