[PATCH] D11363: Allow merging of immediates within a basic block for code size savings and reduced footprint.

Michael Kuperstein michael.m.kuperstein at intel.com
Wed Jul 29 00:41:43 PDT 2015


mkuper added a comment.

Hi Quentin,

I believe Zia is on vacation for a few more days, but this is something we've discussed.
The problem is that ConstantHoisting is useless for multiple usages in the same basic block. 
That is, consider this test-case from the ConstantHoisting pass:

  define i128 @test1(i128 %a) {
    %1 = add i128 %a, 12297829382473034410122878
    %2 = add i128 %1, 12297829382473034410122878
    ret i128 %2
  }

After hoisting, we get this:

  define i128 @test1(i128 %a) {
    %const = bitcast i128 12297829382473034410122878 to i128
    %1 = add i128 %a, %const
    %2 = add i128 %1, %const
    ret i128 %2
  }

>From the DAG's point of view, this is basically a no-op. That is, given this:

  define i32 @test1(i32 %a) {
    %const = bitcast i32 42 to i32 
    %1 = add i32 %a, %const
    %2 = add i32 %1, %const
    ret i32 %2
  }

We sill still pull the constant into the instruction during selection.

It's true that we also want to make the ConstantHoisting heuristic smarter to handle the multi-basic-block cases better, but the instruction selection changes are needed regardless of that.


http://reviews.llvm.org/D11363







More information about the llvm-commits mailing list