[clang] [clang] improve consistency with GCC vector comparison (PR #148954)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 21 06:36:39 PDT 2025


================
@@ -12901,25 +12901,9 @@ QualType Sema::GetSignedVectorType(QualType V) {
     return Context.getExtVectorType(Context.LongLongTy, VTy->getNumElements());
   }
 
-  if (TypeSize == Context.getTypeSize(Context.Int128Ty))
-    return Context.getVectorType(Context.Int128Ty, VTy->getNumElements(),
-                                 VectorKind::Generic);
-  if (TypeSize == Context.getTypeSize(Context.LongLongTy))
-    return Context.getVectorType(Context.LongLongTy, VTy->getNumElements(),
-                                 VectorKind::Generic);
-  if (TypeSize == Context.getTypeSize(Context.LongTy))
-    return Context.getVectorType(Context.LongTy, VTy->getNumElements(),
-                                 VectorKind::Generic);
-  if (TypeSize == Context.getTypeSize(Context.IntTy))
-    return Context.getVectorType(Context.IntTy, VTy->getNumElements(),
-                                 VectorKind::Generic);
-  if (TypeSize == Context.getTypeSize(Context.ShortTy))
-    return Context.getVectorType(Context.ShortTy, VTy->getNumElements(),
-                                 VectorKind::Generic);
-  assert(TypeSize == Context.getTypeSize(Context.CharTy) &&
-         "Unhandled vector element size in vector compare");
-  return Context.getVectorType(Context.CharTy, VTy->getNumElements(),
-                               VectorKind::Generic);
+  QualType ETy = Context.getGCCCompatibleIntTypeForBitwidth(TypeSize, 1);
----------------
erichkeane wrote:

```suggestion
  QualType ETy = Context.getGCCCompatibleIntTypeForBitwidth(TypeSize, /*signed=*/true);
```

https://github.com/llvm/llvm-project/pull/148954


More information about the cfe-commits mailing list