[llvm] [SROA] Allow `llvm.launder.invariant.group` intrinsic to be splittable (PR #72056)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 16 03:16:13 PST 2023
================
@@ -79,6 +79,84 @@ define void @g() {
ret void
}
+define void @store_and_launder() {
+; CHECK-LABEL: @store_and_launder(
+; CHECK-NEXT: ret void
+;
+ %valptr = alloca i32, align 4
+ store i32 0, ptr %valptr, align 4
+ %barr = call ptr @llvm.launder.invariant.group.p0(ptr %valptr)
+ ret void
+}
+
+define i32 @launder_and_load() {
+; CHECK-LABEL: @launder_and_load(
+; CHECK-NEXT: ret i32 undef
+;
+ %valptr = alloca i32, align 4
+ %barr = call ptr @llvm.launder.invariant.group.p0(ptr %valptr)
+ %v2 = load i32, ptr %valptr
+ ret i32 %v2
+}
+
+define void @launder_and_ptr_arith() {
+; CHECK-LABEL: @launder_and_ptr_arith(
+; CHECK-NEXT: ret void
+;
+ %valptr = alloca i32, align 4
+ %barr = call ptr @llvm.launder.invariant.group.p0(ptr %valptr)
+ %a2 = getelementptr inbounds i32, ptr %valptr, i32 0
+ ret void
+}
+
+define void @partial_use_of_alloca() {
+; CHECK-LABEL: @partial_use_of_alloca(
+; CHECK-NEXT: [[VALPTR:%.*]] = alloca i32, align 4
+; CHECK-NEXT: store i32 0, ptr [[VALPTR]], align 4
+; CHECK-NEXT: [[BARR:%.*]] = call ptr @llvm.launder.invariant.group.p0(ptr [[VALPTR]])
+; CHECK-NEXT: [[LOAD_VAL:%.*]] = load i32, ptr [[VALPTR]], align 4
+; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[LOAD_VAL]], 0
+; CHECK-NEXT: br i1 [[COND]], label [[USE_ALLOCA:%.*]], label [[END:%.*]]
+; CHECK: use_alloca:
+; CHECK-NEXT: call void @use(ptr nonnull [[VALPTR]])
+; CHECK-NEXT: br label [[END]]
+; CHECK: end:
+; CHECK-NEXT: ret void
+;
+ %valptr = alloca i32, align 4
+ store i32 0, ptr %valptr, align 4
+ %barr = call ptr @llvm.launder.invariant.group.p0(ptr %valptr)
+ %load_val = load i32, ptr %valptr, align 4
+ %cond = icmp eq i32 %load_val, 0
+ br i1 %cond, label %use_alloca, label %end
+
+use_alloca:
+ call void @use(i32* nonnull %valptr)
----------------
nikic wrote:
```suggestion
call void @use(ptr nonnull %valptr)
```
https://github.com/llvm/llvm-project/pull/72056
More information about the llvm-commits
mailing list