[PATCH] D25466: [InstCombine] Fix constexpr issue in select combining

Andrea Di Biagio via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 11 04:45:27 PDT 2016


andreadb accepted this revision.
andreadb added a comment.
This revision is now accepted and ready to land.

Hi Simon,

the patch looks good to me.
I suggest to improve the test case by adding multiple cases to the switch statement. That would prove that the optimization still works okay even with constant expressions (see below).

Example:

  @g = global i32 0
  
  define i32 @func() {
    switch i32 add (i32 ptrtoint (i32* @g to i32), i32 -1), label %x [
      i32 1, label %one
      i32 2, label %two
    ]
  x:
    ret i32 0
  
  one:
    ret i32 1
  
  two:
    ret i32 2
  }

The above case should be combined to this:

  define i32 @func() {
    switch i32 ptrtoint (i32* @g to i32), label %x [
      i32 2, label %one
      i32 3, label %two
    ]
  
  x:                                                ; preds = %0
    ret i32 0
  
  one:                                              ; preds = %0
    ret i32 1
  
  two:                                              ; preds = %0
    ret i32 2

Thanks!
Andrea


Repository:
  rL LLVM

https://reviews.llvm.org/D25466





More information about the llvm-commits mailing list