[llvm] [InstSimplify] Correctly handle comparison with zero-size allocs (PR #115728)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 12 01:47:52 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]]
----------------
nikic wrote:
Oops, this was actually a mistake in the test. The zero-size allocation was supposed to have `align 1`. It's weird that LLVM infers `align 8` for it by default. I adjusted the test.
InstCombine actually fails to handle this (see https://llvm.godbolt.org/z/WMPKdnrMd for variant without allocas) due to a weakness in foldICmpUsingKnownBits. I'll work on a fix.
https://github.com/llvm/llvm-project/pull/115728
More information about the llvm-commits
mailing list