For casts with constant range operands, we can use
ConstantRange::castOp.
Details
- Reviewers
davide efriedma mssimpso - Commits
- rG0c9c58ada0af: [SCCP] Use constant ranges for casts.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Unit tests: fail. 61132 tests passed, 1 failed and 728 were skipped.
failed: Clang.SemaOpenCL/numbered-address-space.cl
clang-tidy: fail. Please fix clang-tidy findings.
clang-format: pass.
Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml
llvm/lib/Transforms/Scalar/SCCP.cpp | ||
---|---|---|
813 | DL.getTypeSizeInBits(DestTy)? |
Ping. I think all required patches should have landed over the last week or so.
Rebased.
Thanks Eli!
Removed the unnecessary mergeIn.
llvm/lib/Transforms/Scalar/SCCP.cpp | ||
---|---|---|
807 | This could just be markConstant as it was originally I think. Not sure if there are any scenarios where we would get constant after already having a (non-singleton) range. | |
809 | Yep, otherwise we would mark the result of %tmp4 = sitofp i32 %r to double as constant range, if %r is a constant range. |
I'm now getting an assertion failure in the LNT test suite:
http://lab.llvm.org:8011/builders/clang-s390x-linux-lnt/builds/17826/steps/test-suite/logs/stdio
clang: /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/IR/Constants.cpp:1661: static llvm::Constant* llvm::ConstantExpr::getCast(unsigned int, llvm::Constant*, llvm::Type*, bool): Assertion `CastInst::castIsValid(opc, C, Ty) && "Invalid constantexpr cast!"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1.install/bin/clang -DNDEBUG -O3 -DNDEBUG -w -Werror=date-time -w -o CMakeFiles/GCC-C-execute-scal-to-vec1.dir/scal-to-vec1.c.o -c /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/test/test-suite/SingleSource/Regression/C/gcc-c-torture/execute/scal-to-vec1.c
- <eof> parser at end of file
- Per-module optimization passes
- Running pass 'CallGraph Pass Manager' on module '/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/test/test-suite/SingleSource/Regression/C/gcc-c-torture/execute/scal-to-vec1.c'.
- Running pass 'Sparse Conditional Constant Propagation' on function '@main'
[...]
#9 0x000002aa1a5b6b70 llvm::ConstantExpr::getCast(unsigned int, llvm::Constant*, llvm::Type*, bool) (/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1.install/bin/clang+0x2ab6b70)
#10 0x000002aa19ec233c llvm::ConstantFoldCastOperand(unsigned int, llvm::Constant*, llvm::Type*, llvm::DataLayout const&) (/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1.install/bin/clang+0x23c233c)
#11 0x000002aa1ac69ab0 (anonymous namespace)::SCCPSolver::visitCastInst(llvm::CastInst&) (/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1.install/bin/clang+0x3169ab0)
#12 0x000002aa1ac6ce72 llvm::InstVisitor<(anonymous namespace)::SCCPSolver, void>::visit(llvm::Instruction&) (/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1.install/bin/clang+0x316ce72)
[...]
that appears to be directly related to this visitCastInst change.
This is calling both markConstant and mergeInValue?