[clang] [llvm] [LLVM][IRBuilder] Use NUW arithmetic for Create{ElementCount,TypeSize}. (PR #143532)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 10 08:14:43 PDT 2025


================
@@ -177,16 +177,16 @@ define void @add_unique_ind32(ptr noalias nocapture %a, i64 %n) {
 ; CHECK-LABEL: @add_unique_ind32(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
-; CHECK-NEXT:    [[TMP1:%.*]] = shl i64 [[TMP0]], 2
+; CHECK-NEXT:    [[TMP1:%.*]] = shl nuw i64 [[TMP0]], 2
----------------
paulwalker-arm wrote:

This PR is not changing the definition of vscale. It only seeks to strengthen the use of IRBuilder functions `CreateElementCount()` and `CreateTypeSize()` where I'm wanting to mandate their specified result type must be big enough to store the requested value, otherwise the result can be poison.  My rational is that it seems odd to use these functions and not care about generated the correct value.

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


More information about the llvm-commits mailing list