[llvm] [InstCombine] Compare `icmp inttoptr, inttoptr` values directly (PR #107012)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 6 07:33:39 PDT 2024
================
@@ -71,8 +63,7 @@ define i1 @inttoptr_size_mismatch(i200 %x, i9 %y) {
define <2 x i1> @inttoptr_vector_constant_size_mismatch(<2 x i200> %x) {
; CHECK-LABEL: @inttoptr_vector_constant_size_mismatch(
; CHECK-NEXT: [[TMP1:%.*]] = trunc <2 x i200> [[X:%.*]] to <2 x i64>
-; CHECK-NEXT: [[XPTR:%.*]] = inttoptr <2 x i64> [[TMP1]] to <2 x ptr>
-; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x ptr> [[XPTR]], <ptr inttoptr (i9 42 to ptr), ptr inttoptr (i9 123 to ptr)>
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i64> [[TMP1]], <i64 42, i64 123>
----------------
nikic wrote:
No, I mean to replace `NewOp1 = ConstantExpr::getPtrToInt(RHSC, SrcTy);` with `NewOp1 = Builder.CreateIntToPtr(RHSC, SrcTy);`
The difference is that the IRBuilder will perform DataLayout-aware constant folding.
You could also directly invoke the ConstantFoldCastOperand() API, but going through IRBuilder is preferred in this context.
https://github.com/llvm/llvm-project/pull/107012
More information about the llvm-commits
mailing list