[PATCH] D87188: [InstCombine] Canonicalize SPF to abs intrinc

Nuno Lopes via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 22 06:26:05 PST 2020


nlopes added a comment.

This patch regressed the following test of Transforms/InstCombine/abs-1.ll:
(need to drop NSW in this case).

  define i8 @nabs_canonical_3(i8 %x) {
  %0:
    %cmp = icmp slt i8 %x, 0
    %neg = sub nsw i8 0, %x
    %abs = select i1 %cmp, i8 %x, i8 %neg
    ret i8 %abs
  }
  =>
  define i8 @nabs_canonical_3(i8 %x) {
  %0:
    %1 = abs i8 %x, 1
    %abs = sub nsw i8 0, %1
    ret i8 %abs
  }
  Transformation doesn't verify!
  ERROR: Target is more poisonous than source
  
  Example:
  i8 %x = #x80 (128, -128)
  
  Source:
  i1 %cmp = #x1 (1)
  i8 %neg = poison
  i8 %abs = #x80 (128, -128)
  
  Target:
  i8 %1 = poison
  i8 %abs = poison
  Source value: #x80 (128, -128)
  Target value: poison

(same bug occurs with @nabs_nabs_x01 in Transforms/InstCombine/abs_abs.ll)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87188/new/

https://reviews.llvm.org/D87188



More information about the cfe-commits mailing list