[PATCH] D60395: [InstCombine] Canonicalize (-X s/ Y) to -(X s/ Y)
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 8 07:37:59 PDT 2019
lebedev.ri added a comment.
Almost there.
Since we never touch the denominator, i think we are always good re vectors.
Does this need rebasing now that the other patch has landed?
================
Comment at: llvm/test/Transforms/InstCombine/sdiv-canonicalize.ll:7
+; CHECK-NEXT: [[SDIV1:%.*]] = sdiv i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[SDIV:%.*]] = sub i32 0, [[SDIV1]]
; CHECK-NEXT: ret i32 [[SDIV]]
----------------
Shouldn't this `sub` also be `nsw`?
```
----------------------------------------
Optimization: nsw preserved
Precondition: true
%o0 = sub nsw i8 0, %x
%r = sdiv i8 %o0, %y
=>
%n0 = sdiv i8 %x, %y
%r = sub nsw i8 0, %n0
Done: 1
Optimization is correct!
----------------------------------------
Optimization: exact preserved
Precondition: true
%o0 = sub nsw i8 0, %x
%r = sdiv exact i8 %o0, %y
=>
%n0 = sdiv exact i8 %x, %y
%r = sub i8 0, %n0
Done: 1
Optimization is correct!
----------------------------------------
Optimization: both preserved
Precondition: true
%o0 = sub nsw i8 0, %x
%r = sdiv exact i8 %o0, %y
=>
%n0 = sdiv exact i8 %x, %y
%r = sub nsw i8 0, %n0
Done: 1
Optimization is correct!
```
================
Comment at: llvm/test/Transforms/InstCombine/sdiv-canonicalize.ll:11
%neg = sub nsw i32 0, %x
%sdiv = sdiv i32 %neg, %y
ret i32 %sdiv
----------------
There is a test that will show that we propagate `exact`?
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60395/new/
https://reviews.llvm.org/D60395
More information about the llvm-commits
mailing list