[clang] [llvm] [IR] Avoid creating icmp/fcmp constant expressions (PR #92885)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue May 21 13:16:13 PDT 2024


================
@@ -8,7 +8,8 @@
 // CHECK:      entry:
 // CHECK-NEXT:   %retval = alloca i32
 // CHECK-NEXT:   store i32 0, ptr %retval
-// CHECK-NEXT:   [[ZEXT:%.*]] = zext i1 true to i32
+// CHECK-NEXT:   [[CMP:%.*]] = icmp ne ptr @b, @a
+// CHECK-NEXT:   [[ZEXT:%.*]] = zext i1 [[CMP]] to i32
----------------
nikic wrote:

I remember looking into this test a while ago (the `zext i1 true` is pretty weird, usually IRBuilder would fold that away) and the context is that one of the values here gets RAUWed and that would enable the folding. For constant expressions, replacing an operand will also re-fold the expression. For instructions, this doesn't happen. In any case, it will get folded later if optimizations are enabled.

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


More information about the llvm-commits mailing list