[PATCH] D38546: [ConstantFolding] Avoid assert when folding ptrtoint of vectorized GEP

Filipe Cabecinhas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 16 11:44:29 PDT 2017


filcab requested changes to this revision.
filcab added a comment.
This revision now requires changes to proceed.

Hi @bjope,

Thanks for the patch, but it seems to be trying to paper over another problem instead of fixing it.
I've commented on the specific line where I have concerns.

Thank you,

Filipe



================
Comment at: test/Analysis/ConstantFolding/cast-vector.ll:10
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    ret <2 x i16> ptrtoint (<2 x i32*> getelementptr ([10 x i32], [10 x i32]* null, <2 x i64> zeroinitializer, <2 x i64> <i64 5, i64 7>) to <2 x i16>)
+;
----------------
This is invalid IR (per langref). the `ptrtoint` constant expression only takes a pointer type argument:

> ptrtoint (CST to TYPE)
> Convert a pointer typed constant to the corresponding integer constant. TYPE must be an integer type. CST must be of pointer type. The CST value is zero extended, truncated, or unchanged to make it fit in TYPE.

It seems to me that one of the following is the best fix:
  - Fix whatever is creating a `ptrtoint` constant expression with a vector argument (make sure to also add an assert to make sure it doesn't happen again)
  - Make `ptrtoint` of vectors a valid constant expression, which involves changing the langref and making sure these kinds of folds are valid.





https://reviews.llvm.org/D38546





More information about the llvm-commits mailing list