LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 42619 - DivRemPairs is incorrect in the presence of undef
Summary: DivRemPairs is incorrect in the presence of undef
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Scalar Optimizations (show other bugs)
Version: trunk
Hardware: All All
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks: 47948
  Show dependency tree
 
Reported: 2019-07-14 08:17 PDT by Nuno Lopes
Modified: 2020-10-22 09:41 PDT (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nuno Lopes 2019-07-14 08:17:57 PDT
See, for example:

$ opt -div-rem-pairs Transforms/DivRemPairs/X86/div-rem-pairs.ll

define void @decompose_illegal_srem_same_block(i32 %a, i32 %b) {
  %rem = srem i32 %a, %b
  %div = sdiv i32 %a, %b
  call void @foo(i32 %rem, i32 %div)
  ret void
}
=>
define void @decompose_illegal_srem_same_block(i32 %a, i32 %b) {
  %div = sdiv i32 %a, %b
  %1 = mul i32 %div, %b
  %2 = sub i32 %a, %1
  call void @foo(i32 %2, i32 %div)
  ret void
}
Transformation doesn't verify!
ERROR: Source is more defined than target

Example:
i32 %a = undef
i32 %b = #x00000001 (1)

Source:
i32 %rem = #x00000000 (0)
i32 %div = undef

Target:
i32 %div = #x7fffffff (2147483647)
i32 %1 = undef
i32 %2 = undef
Comment 1 Sanjay Patel 2020-03-20 05:49:10 PDT
Fix proposed here:
https://reviews.llvm.org/D76483