[llvm] r209746 - InstCombine: Improvement to check if signed addition overflows.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Fri May 30 12:06:57 PDT 2014


> Strangely though, removing the symmetric call gives good result of
> test-func.ll you had provided (I donno how but it works, even though the
> second call would be dead).

Well, we have to understand what is wrong with it.

The testcase reduces to just

define i32 @foo(i32 %x, i1 %y) {
  %v1 = sext i1 %y to i32
  %v2 = add i32 %v1, -1
  ret i32 %v2
}

which with the patch gets converted to

define i32 @foo(i32 %x, i1 %y) {
  %addconv = xor i1 %y, true
  %v2 = sext i1 %addconv to i32
  ret i32 %v2
}

Can you step over instcombine and see what invalid transformation is being done?

Cheers,
Rafael



More information about the llvm-commits mailing list