[llvm] [InstSimplify] Correctly handle comparison with zero-size allocs (PR #115728)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 11 16:28:16 PST 2024


================
@@ -249,8 +250,10 @@ define i1 @zst_alloca_middle() {
 ; CHECK-LABEL: @zst_alloca_middle(
 ; CHECK-NEXT:    [[A:%.*]] = alloca i64, align 8
 ; CHECK-NEXT:    [[A2:%.*]] = alloca {}, align 8
+; CHECK-NEXT:    [[GEP:%.*]] = getelementptr i8, ptr [[A]], i64 4
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq ptr [[GEP]], [[A2]]
 ; CHECK-NEXT:    call void @escape(ptr [[A]], ptr [[A2]])
-; CHECK-NEXT:    ret i1 false
+; CHECK-NEXT:    ret i1 [[CMP]]
----------------
dtcxzyw wrote:

Can you add an InstCombine test to demonstrate that this case can be folded using KnownBits (`??000` != `??100`)?


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


More information about the llvm-commits mailing list