[PATCH] D113495: [TypePromotion] Fix a hardcoded use of 32 as the size being promoted to.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 9 09:52:08 PST 2021


craig.topper created this revision.
craig.topper added a reviewer: samparker.
Herald added a subscriber: hiraditya.
craig.topper requested review of this revision.
Herald added a project: LLVM.

At least I think that's what the 32 here is. Use RegisterBitWidth
instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113495

Files:
  llvm/lib/CodeGen/TypePromotion.cpp


Index: llvm/lib/CodeGen/TypePromotion.cpp
===================================================================
--- llvm/lib/CodeGen/TypePromotion.cpp
+++ llvm/lib/CodeGen/TypePromotion.cpp
@@ -359,11 +359,8 @@
     return false;
 
   // Now check that the result can't wrap on itself.
-  APInt Total = ICmpConst->getValue().getBitWidth() < 32 ?
-    ICmpConst->getValue().zext(32) : ICmpConst->getValue();
-
-  Total += OverflowConst->getValue().getBitWidth() < 32 ?
-    OverflowConst->getValue().abs().zext(32) : OverflowConst->getValue().abs();
+  APInt Total = ICmpConst->getValue().zextOrSelf(RegisterBitWidth);
+  Total += OverflowConst->getValue().abs().zextOrSelf(RegisterBitWidth);
 
   APInt Max = APInt::getAllOnes(TypePromotion::TypeSize);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113495.385862.patch
Type: text/x-patch
Size: 753 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211109/521dd0f5/attachment.bin>


More information about the llvm-commits mailing list