[llvm] [InstCombine] Compare `icmp inttoptr, inttoptr` values directly (PR #107012)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 13 02:30:59 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:
I looked into it, and the problem is that ConstantFoldCastInst expects the operand of the ptrtoint to be an inttoptr expression, but here it is a vector of inttoptr. The fold only works after the ptrtoint has been applied element-wise to the vector elements. We should probably fix the constant folding API to make this work directly, but for now you can work around it like this: `ConstantFoldConstant(ConstantExpr::getPtrToInt(RHSC, SrcTy), DL)`
https://github.com/llvm/llvm-project/pull/107012
More information about the llvm-commits
mailing list