[PATCH] D12988: [Bug 24848] Use range metadata to constant fold comparisons with constant values

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 16:13:12 PDT 2015


sanjoy added a comment.

I think this looks ready to go in.  @hfinkel WDYT?


================
Comment at: lib/Analysis/InstructionSimplify.cpp:2131
@@ -2130,1 +2130,3 @@
 
+static ConstantRange GetConstantRangeFromMetadata(MDNode *Ranges, uint32_t BitWidth) {
+  const unsigned NumRanges = Ranges->getNumOperands() / 2;
----------------
There is also a similar `GetRangeFromMetadata` function in `ScalarEvolution`.  As a later patch you might want to common the two (totally optional).

================
Comment at: lib/Analysis/InstructionSimplify.cpp:2133
@@ +2132,3 @@
+  const unsigned NumRanges = Ranges->getNumOperands() / 2;
+  assert(NumRanges >= 1);
+
----------------
Since you're asserting here anyway, I'd make this stronger: `assert(NumRanges >= 1 && Ranges->getNumOperands() % 2 == 0 && "Ill formed IR!");`


http://reviews.llvm.org/D12988





More information about the llvm-commits mailing list