[clang] [llvm] [LLVM][IRBuilder] Use NUW arithmetic for Create{ElementCount,TypeSize}. (PR #143532)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 10 08:04:51 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
----------------
fhahn wrote:
I guess the code here already implicitly assumes that the multiply does not overflow, but it is not immedately clear how this follows from the definition of `llvm.vscale` in LangRef, which says only limits `vscale` to a positive constant:
```
vscale is a positive value that is constant throughout program execution, but is unknown at compile time. If the result value does not fit in the result type, then the result is a [poison value](https://llvm.org/docs/LangRef.html#poisonvalues).
```
https://github.com/llvm/llvm-project/pull/143532
More information about the llvm-commits
mailing list