[llvm] 37c9171 - [ConstantFold] Add test for invalid non-inbounds gep icmp fold

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 6 00:59:47 PST 2022


Author: Nikita Popov
Date: 2022-01-06T09:59:40+01:00
New Revision: 37c9171764ee1a1ce34cd5cf984fee818cd617fb

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

LOG: [ConstantFold] Add test for invalid non-inbounds gep icmp fold

The gep evaluated to null in this case, and as such is not ne null.

Added: 
    

Modified: 
    llvm/test/Transforms/InstSimplify/ConstProp/icmp-global.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstSimplify/ConstProp/icmp-global.ll b/llvm/test/Transforms/InstSimplify/ConstProp/icmp-global.ll
index aeb6ab4e504f..bac75d3788d5 100644
--- a/llvm/test/Transforms/InstSimplify/ConstProp/icmp-global.ll
+++ b/llvm/test/Transforms/InstSimplify/ConstProp/icmp-global.ll
@@ -92,8 +92,16 @@ define i1 @global_sgt_null() {
   ret i1 %cmp
 }
 
-define i1 @global_gep_ne_null() {
-; CHECK-LABEL: @global_gep_ne_null(
+define i1 @global_out_of_bounds_gep_ne_null() {
+; CHECK-LABEL: @global_out_of_bounds_gep_ne_null(
+; CHECK-NEXT:    ret i1 true
+;
+  %cmp = icmp ne i8* getelementptr (i8, i8* @g3, i64 sub (i64 0, i64 ptrtoint (i8* @g3 to i64))), null
+  ret i1 %cmp
+}
+
+define i1 @global_inbounds_gep_ne_null() {
+; CHECK-LABEL: @global_inbounds_gep_ne_null(
 ; CHECK-NEXT:    ret i1 true
 ;
   %gep = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 1


        


More information about the llvm-commits mailing list