[llvm] e69c21f - [InstCombine] Add test for atomic load from constant global (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 22 02:16:00 PDT 2022


Author: Nikita Popov
Date: 2022-04-22T11:15:50+02:00
New Revision: e69c21f75b233c69d454c03d5a9d99befe7ba76e

URL: https://github.com/llvm/llvm-project/commit/e69c21f75b233c69d454c03d5a9d99befe7ba76e
DIFF: https://github.com/llvm/llvm-project/commit/e69c21f75b233c69d454c03d5a9d99befe7ba76e.diff

LOG: [InstCombine] Add test for atomic load from constant global (NFC)

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/atomic.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/atomic.ll b/llvm/test/Transforms/InstCombine/atomic.ll
index 1182da0f6a3c5..ef838e735312f 100644
--- a/llvm/test/Transforms/InstCombine/atomic.ll
+++ b/llvm/test/Transforms/InstCombine/atomic.ll
@@ -421,4 +421,33 @@ define void @no_atomic_vector_store(<2 x float> %p, i8* %p2) {
   ret void
 }
 
+ at c = constant i32 42
+
+define i32 @atomic_load_from_constant_global() {
+; CHECK-LABEL: @atomic_load_from_constant_global(
+; CHECK-NEXT:    [[V:%.*]] = load atomic i32, i32* @c seq_cst, align 4
+; CHECK-NEXT:    ret i32 42
+;
+  %v = load atomic i32, i32* @c seq_cst, align 4
+  ret i32 %v
+}
+
+define i8 @atomic_load_from_constant_global_bitcast() {
+; CHECK-LABEL: @atomic_load_from_constant_global_bitcast(
+; CHECK-NEXT:    [[V:%.*]] = load atomic i8, i8* bitcast (i32* @c to i8*) seq_cst, align 1
+; CHECK-NEXT:    ret i8 42
+;
+  %v = load atomic i8, i8* bitcast (i32* @c to i8*) seq_cst, align 1
+  ret i8 %v
+}
+
+define void @volatile_load_from_constant_global() {
+; CHECK-LABEL: @volatile_load_from_constant_global(
+; CHECK-NEXT:    [[TMP1:%.*]] = load volatile i32, i32* @c, align 4
+; CHECK-NEXT:    ret void
+;
+  load volatile i32, i32* @c, align 4
+  ret void
+}
+
 attributes #0 = { null_pointer_is_valid }


        


More information about the llvm-commits mailing list