[InstCombine] Add test for infinite combine loop (NFC)
authorNikita Popov <npopov@redhat.com>
Mon, 24 Jul 2023 10:43:52 +0000 (12:43 +0200)
committerNikita Popov <npopov@redhat.com>
Mon, 24 Jul 2023 10:44:36 +0000 (12:44 +0200)
Guard against the issue reported at
https://reviews.llvm.org/rG086ee99564af#1230303.

llvm/test/Transforms/InstCombine/and.ll

index cfbf2a8..51fc00c 100644 (file)
@@ -2427,3 +2427,14 @@ define i8 @negate_lowbitmask_use2(i8 %x, i8 %y) {
   %r = and i8 %n, %y
   ret i8 %r
 }
+
+@g = external global i64
+
+define i64 @test_and_or_constexpr_infloop() {
+; CHECK-LABEL: @test_and_or_constexpr_infloop(
+; CHECK-NEXT:    ret i64 or (i64 and (i64 ptrtoint (ptr @g to i64), i64 -8), i64 1)
+;
+  %and = and i64 ptrtoint (ptr @g to i64), -8
+  %or = or i64 %and, 1
+  ret i64 %or
+}